-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renderer defaults to an id-prefix of "form" (because e.g. radio/check…
…box groups aren't possible without an id)
- Loading branch information
Rasmus Schultz
committed
May 18, 2016
1 parent
6cae08c
commit ee02a68
Showing
3 changed files
with
45 additions
and
42 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
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 |
---|---|---|
|
@@ -26,38 +26,38 @@ public function renderTextFields(UnitTester $I) | |
$model = $form->model; | ||
$field = new TextField('value'); | ||
|
||
$I->assertSame('<input class="form-control" name="value" type="text"/>', $form->render($field), | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" type="text"/>', $form->render($field), | ||
'basic input with no value-attribute'); | ||
|
||
$field->setValue($model, 'Hello World'); | ||
|
||
$I->assertSame('<input class="form-control" name="value" type="text" value="Hello World"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" type="text" value="Hello World"/>', | ||
$form->render($field), 'basic input with value-attribute'); | ||
|
||
$field->max_length = 50; | ||
|
||
$I->assertSame('<input class="form-control" maxlength="50" name="value" type="text" value="Hello World"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" maxlength="50" name="value" type="text" value="Hello World"/>', | ||
$form->render($field), 'input with value and maxlength-attribute'); | ||
|
||
$field->setPlaceholder('hello'); | ||
|
||
$I->assertSame('<input class="form-control" maxlength="50" name="value" placeholder="hello" type="text" value="Hello World"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" maxlength="50" name="value" placeholder="hello" type="text" value="Hello World"/>', | ||
$form->render($field), 'input with value, maxlength and placeholder-attributes'); | ||
$I->assertSame('<input class="form-control" data-foo="bar" maxlength="50" name="value" placeholder="hello" type="text" value="Hello World"/>', | ||
$I->assertSame('<input class="form-control" data-foo="bar" id="form-value" maxlength="50" name="value" placeholder="hello" type="text" value="Hello World"/>', | ||
$form->render($field, ['data-foo' => 'bar']), 'input with custom data-attribute overridden'); | ||
$I->assertSame('<input class="form-control" maxlength="50" name="value" placeholder="override" type="text" value="Hello World"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" maxlength="50" name="value" placeholder="override" type="text" value="Hello World"/>', | ||
$form->render($field, ['placeholder' => 'override']), 'input with placeholder-attribute overridden'); | ||
|
||
$field->setValue($model, 'this & that'); | ||
|
||
$I->assertSame('<input class="form-control" maxlength="50" name="value" placeholder="hello" type="text" value="this & that"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" maxlength="50" name="value" placeholder="hello" type="text" value="this & that"/>', | ||
$form->render($field), 'input with value-attribute escaped as HTML'); | ||
|
||
$field = new TextField("value"); | ||
|
||
$field->setPattern('[A-Z]{2}', 'Enter two-letter ISO language code'); | ||
|
||
$I->assertSame('<input class="form-control" data-pattern-error="Enter two-letter ISO language code" name="value" pattern="[A-Z]{2}" type="text" value="this & that"/>', | ||
$I->assertSame('<input class="form-control" data-pattern-error="Enter two-letter ISO language code" id="form-value" name="value" pattern="[A-Z]{2}" type="text" value="this & that"/>', | ||
$form->render($field)); | ||
} | ||
|
||
|
@@ -69,7 +69,7 @@ public function renderPasswordField(UnitTester $I) | |
|
||
$field->setValue($model, 'supersecret'); | ||
|
||
$I->assertSame('<input class="form-control" name="value" type="password" value=""/>', $form->render($field), | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" type="password" value=""/>', $form->render($field), | ||
'input with type=password'); | ||
} | ||
|
||
|
@@ -93,7 +93,7 @@ public function renderEmailField(UnitTester $I) | |
|
||
$field->setValue($model, '[email protected]'); | ||
|
||
$I->assertSame('<input class="form-control" name="value" type="email" value="[email protected]"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" type="email" value="[email protected]"/>', | ||
$form->render($field), 'input with type=email (html5)'); | ||
} | ||
|
||
|
@@ -105,7 +105,7 @@ public function renderTextArea(UnitTester $I) | |
|
||
$field->setValue($model, 'this & that'); | ||
|
||
$I->assertSame('<textarea class="form-control" name="value">this & that</textarea>', $form->render($field), | ||
$I->assertSame('<textarea class="form-control" id="form-value" name="value">this & that</textarea>', $form->render($field), | ||
'simple textarea with content'); | ||
} | ||
|
||
|
@@ -154,22 +154,22 @@ public function renderSelectTags(UnitTester $I) | |
2 => 'Option Two', | ||
]); | ||
|
||
$I->assertSame('<select class="form-control" name="value"><option value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$I->assertSame('<select class="form-control" id="form-value" name="value"><option value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$form->render($field)); | ||
|
||
$field->setValue($form->model, 1); | ||
|
||
$I->assertSame('<select class="form-control" name="value"><option selected value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$I->assertSame('<select class="form-control" id="form-value" name="value"><option selected value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$form->render($field)); | ||
|
||
$field->disabled = 'Please select'; | ||
|
||
$I->assertSame('<select class="form-control" name="value"><option disabled>Please select</option><option selected value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$I->assertSame('<select class="form-control" id="form-value" name="value"><option disabled>Please select</option><option selected value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$form->render($field)); | ||
|
||
$field->setValue($form->model, null); | ||
|
||
$I->assertSame('<select class="form-control" name="value"><option disabled selected>Please select</option><option value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$I->assertSame('<select class="form-control" id="form-value" name="value"><option disabled selected>Please select</option><option value="1">Option One</option><option value="2">Option Two</option></select>', | ||
$form->render($field)); | ||
} | ||
|
||
|
@@ -204,16 +204,16 @@ public function renderIntField(UnitTester $I) | |
|
||
$field = new IntField("value"); | ||
|
||
$I->assertSame('<input class="form-control" name="value" pattern="-?\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" pattern="-?\d*" type="number"/>', $form->render($field)); | ||
|
||
$field->min_value = -1; | ||
|
||
$I->assertSame('<input class="form-control" min="-1" name="value" pattern="-?\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" min="-1" name="value" pattern="-?\d*" type="number"/>', $form->render($field)); | ||
|
||
$field->min_value = 1; | ||
$field->max_value = 99; | ||
|
||
$I->assertSame('<input class="form-control" max="99" min="1" name="value" pattern="\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" max="99" min="1" name="value" pattern="\d*" type="number"/>', $form->render($field)); | ||
} | ||
|
||
public function renderFloatField(UnitTester $I) | ||
|
@@ -222,16 +222,16 @@ public function renderFloatField(UnitTester $I) | |
|
||
$field = new FloatField("value"); | ||
|
||
$I->assertSame('<input class="form-control" name="value" pattern="-?\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" pattern="-?\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
|
||
$field->min_value = -1; | ||
|
||
$I->assertSame('<input class="form-control" min="-1" name="value" pattern="-?\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" min="-1" name="value" pattern="-?\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
|
||
$field->min_value = 1; | ||
$field->max_value = 99; | ||
|
||
$I->assertSame('<input class="form-control" max="99" min="1" name="value" pattern="\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
$I->assertSame('<input class="form-control" id="form-value" max="99" min="1" name="value" pattern="\d*(\.(?=\d))?\d*" type="number"/>', $form->render($field)); | ||
} | ||
|
||
public function renderDateTimeField(UnitTester $I) | ||
|
@@ -240,7 +240,7 @@ public function renderDateTimeField(UnitTester $I) | |
$field = new DateTimeField('value', 'Europe/Copenhagen', 'Y-m-d H:i:s', ['readonly' => true]); | ||
$field->setValue($form->model, 173919600); | ||
|
||
$I->assertSame('<input class="form-control" name="value" readonly type="text" value="1975-07-07 00:00:00"/>', | ||
$I->assertSame('<input class="form-control" id="form-value" name="value" readonly type="text" value="1975-07-07 00:00:00"/>', | ||
$form->render($field)); | ||
} | ||
|
||
|
@@ -269,17 +269,17 @@ public function renderDateSelector(UnitTester $I) | |
|
||
$I->expectParts( | ||
$form->render($field), [ | ||
'<select class="form-control day" name="value[day]">', | ||
'<select class="form-control day" id="form-value-day" name="value[day]">', | ||
'<option value="1">1</option>', | ||
'<option selected value="7">7</option>', | ||
'<option value="31">31</option>', | ||
'</select>', | ||
'<select class="form-control month" name="value[month]">', | ||
'<select class="form-control month" id="form-value-month" name="value[month]">', | ||
'<option value="1">January</option>', | ||
'<option selected value="7">July</option>', | ||
'<option value="12">December</option>', | ||
'</select>', | ||
'<select class="form-control year" name="value[year]">', | ||
'<select class="form-control year" id="form-value-year" name="value[year]">', | ||
'<option value="1974">1974</option>', | ||
'<option selected value="1975">1975</option>', | ||
'<option value="1976">1976</option>', | ||
|
@@ -291,11 +291,11 @@ public function renderDateSelector(UnitTester $I) | |
|
||
$I->expectParts( | ||
$form->render($field), [ | ||
'<select class="form-control day" name="value[day]">', | ||
'<select class="form-control day" id="form-value-day" name="value[day]">', | ||
'<option disabled>Day</option>', | ||
'<select class="form-control month" name="value[month]">', | ||
'<select class="form-control month" id="form-value-month" name="value[month]">', | ||
'<option disabled>Month</option>', | ||
'<select class="form-control year" name="value[year]">', | ||
'<select class="form-control year" id="form-value-year" name="value[year]">', | ||
'<option disabled>Year</option>', | ||
] | ||
); | ||
|
@@ -304,11 +304,11 @@ public function renderDateSelector(UnitTester $I) | |
|
||
$I->expectParts( | ||
$form->render($field), [ | ||
'<select class="form-control day" name="value[day]">', | ||
'<select class="form-control day" id="form-value-day" name="value[day]">', | ||
'<option disabled selected>Day</option>', | ||
'<select class="form-control month" name="value[month]">', | ||
'<select class="form-control month" id="form-value-month" name="value[month]">', | ||
'<option disabled selected>Month</option>', | ||
'<select class="form-control year" name="value[year]">', | ||
'<select class="form-control year" id="form-value-year" name="value[year]">', | ||
'<option disabled selected>Year</option>', | ||
] | ||
); | ||
|
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