-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Forms\ControlGroup. | ||
*/ | ||
|
||
use Tester\Assert; | ||
use Nette\Forms\ControlGroup; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
function createContainer() { | ||
$container = new Nette\Forms\Container; | ||
$container->addText('street', 'Street'); | ||
$container->addText('town', 'Town'); | ||
return $container; | ||
} | ||
|
||
$form = new Nette\Forms\Form; | ||
|
||
|
||
// controls only | ||
$group = $form->addGroup(); | ||
$form->addText('name', 'Name'); | ||
$form->addText('surname', 'Surname'); | ||
|
||
Assert::same($group, $form->getGroup(0)); | ||
Assert::true($form->getGroup(0) instanceof ControlGroup); | ||
Assert::equal(2, count($group->getControls())); | ||
Assert::equal(array($form['name'], $form['surname']), $group->getControls()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<form action="" method="post"> | ||
|
||
<fieldset> | ||
<table> | ||
<tr> | ||
<th><label for="frm-name">Name</label></th> | ||
|
||
<td><input type="text" name="name" id="frm-name" class="text"></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><label for="frm-surname">Surname</label></th> | ||
|
||
<td><input type="text" name="surname" id="frm-surname" class="text"></td> | ||
</tr> | ||
</table> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Address</legend> | ||
|
||
<table> | ||
<tr> | ||
<th><label for="frm-note">Note</label></th> | ||
|
||
<td><textarea name="note" id="frm-note"></textarea></td> | ||
</tr> | ||
</table> | ||
</fieldset> | ||
|
||
<table> | ||
<tr> | ||
<th><label for="frm-address-street">Street</label></th> | ||
|
||
<td><input type="text" name="address[street]" id="frm-address-street" class="text"></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><label for="frm-address-town">Town</label></th> | ||
|
||
<td><input type="text" name="address[town]" id="frm-address-town" class="text"></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><label for="frm-address-country">Country</label></th> | ||
|
||
<td><input type="text" name="address[country]" id="frm-address-country" class="text"></td> | ||
</tr> | ||
|
||
<tr> | ||
<th></th> | ||
|
||
<td><input type="submit" name="_submit" value="Order" class="button"></td> | ||
</tr> | ||
</table> | ||
|
||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Forms default rendering containers inside groups. | ||
*/ | ||
|
||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
function createContainer() { | ||
$container = new Nette\Forms\Container; | ||
$container->addText('street', 'Street'); | ||
$container->addText('town', 'Town'); | ||
$container->addText('country', 'Country'); | ||
return $container; | ||
} | ||
|
||
$form = new Nette\Forms\Form; | ||
|
||
// controls only | ||
$form->addGroup(); | ||
$form->addText('name', 'Name'); | ||
$form->addText('surname', 'Surname'); | ||
|
||
// container is ignored | ||
$form->addGroup('Address'); | ||
$form->addComponent(createContainer(), 'address'); | ||
|
||
$form->addTextArea('note', 'Note'); | ||
$form->setCurrentGroup(); | ||
$form->addSubmit('submit', 'Order'); | ||
|
||
$form->fireEvents(); | ||
|
||
Assert::matchFile(__DIR__ . '/Forms.renderer.5.expect', $form->__toString(TRUE)); |