Reflecting new radio signature in usage, and adding tests for separator usage

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5749 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-10-11 16:45:23 +00:00
parent e7bccfe7a8
commit b06c7f88e2
2 changed files with 9 additions and 10 deletions

View file

@ -517,14 +517,6 @@ class FormHelper extends AppHelper {
}
unset($options['options']);
}
$inBetween = null;
if (isset($options['inbetween'])) {
if (!empty($options['inbetween'])) {
$inBetween = $options['inbetween'];
}
unset($options['inbetween']);
}
}
if (!isset($options['type'])) {
@ -670,7 +662,7 @@ class FormHelper extends AppHelper {
$out = $before . $this->checkbox($fieldName, $options) . $between . $out;
break;
case 'radio':
$out = $before . $out . $this->radio($fieldName, $radioOptions, $inBetween, $options) . $between;
$out = $before . $out . $this->radio($fieldName, $radioOptions, $options) . $between;
break;
case 'text':
case 'password':

View file

@ -478,9 +478,16 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/id="Field1"/', $result);
$this->assertNoPattern('/id="ModelField"/', $result);
$this->assertNoPattern('/checked="checked"/', $result);
$this->assertPattern('/^<fieldset><legend>field<\/legend>(<input[^<>]+><label[^<>]+>option [AB]<\/label>)+<\/fieldset>$/', $result);
$this->assertPattern('/(<input[^<>]+name="data\[Model\]\[field\]"[^<>]+>.+){2}/', $result);
$result = $this->Form->radio('Model.field', array('option A', 'option B'), array('separator' => '<br/>'));
$this->assertPattern('/id="Field0"/', $result);
$this->assertPattern('/id="Field1"/', $result);
$this->assertNoPattern('/id="ModelField"/', $result);
$this->assertNoPattern('/checked="checked"/', $result);
$this->assertPattern('/^<fieldset><legend>field<\/legend><input[^<>]+><label[^<>]+>option A<\/label><br[^<>+]><input[^<>]+><label[^<>]+>option B<\/label><\/fieldset>$/', $result);
$this->assertPattern('/(<input[^<>]+name="data\[Model\]\[field\]"[^<>]+>.+){2}/', $result);
$result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => '1'));
$this->assertPattern('/id="Field1".*checked="checked"/', $result);