Fixing PHP error with $divOptions in FormHelper::input() when passing $option['div'] = false

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7066 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
joelmoss 2008-05-30 16:05:53 +00:00
parent 03322a31d7
commit d294e91d42
2 changed files with 5 additions and 5 deletions

View file

@ -615,6 +615,7 @@ class FormHelper extends AppHelper {
$out = '';
$div = true;
$divOptions = array();
if (array_key_exists('div', $options)) {
$div = $options['div'];
@ -622,7 +623,7 @@ class FormHelper extends AppHelper {
}
if (!empty($div)) {
$divOptions = array('class' => 'input');
$divOptions['class'] = 'input';
$divOptions = $this->addClass($divOptions, $options['type']);
if (is_string($div)) {
$divOptions['class'] = $div;
@ -768,7 +769,7 @@ class FormHelper extends AppHelper {
}
}
}
if (isset($divOptions)) {
if ($divOptions && isset($divOptions['tag'])) {
$tag = $divOptions['tag'];
unset($divOptions['tag']);
$out = $this->Html->tag($tag, $out, $divOptions);

View file

@ -835,18 +835,17 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Model.field', array('div' => array('tag' => 'span'), 'error' => array('wrap' => 'span')));
$result = $this->Form->input('Model.field', array('div' => false, 'error' => array('wrap' => 'span')));
$expected = array(
'span' => array('class' => 'input text error'),
'label' => array('for' => 'ModelField'),
'Field',
'/label',
'input' => array('type' => 'text', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField', 'class' => 'form-error'),
array('span' => array('class' => 'error-message')),
'Badness!',
'/span',
'/span'
);
// debug($result);exit;
$this->assertTags($result, $expected);
$result = $this->Form->input('Model.field', array('div' => array('tag' => 'span'), 'error' => array('wrap' => false)));