mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix hiddenField option not working for radio.
The hiddenField option was not working as documented for radio buttons. Instead of using the provided value, the hidden input's value was hardcoded to '' Refs #11002
This commit is contained in:
parent
dca1289eef
commit
be534eacef
2 changed files with 25 additions and 1 deletions
|
@ -4944,6 +4944,30 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test setting a hiddenField value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRadioHiddenFieldValue() {
|
||||||
|
$result = $this->Form->input('Model.1.field', array(
|
||||||
|
'type' => 'radio',
|
||||||
|
'options' => array('option A'),
|
||||||
|
'hiddenField' => 'N'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$expected = array(
|
||||||
|
'div' => array('class' => 'input radio'),
|
||||||
|
array('input' => array('type' => 'hidden', 'name' => 'data[Model][1][field]', 'value' => 'N', 'id' => 'Model1Field_')),
|
||||||
|
array('input' => array('type' => 'radio', 'name' => 'data[Model][1][field]', 'value' => '0', 'id' => 'Model1Field0')),
|
||||||
|
'label' => array('for' => 'Model1Field0'),
|
||||||
|
'option A',
|
||||||
|
'/label',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test adding an empty option for radio buttons
|
* test adding an empty option for radio buttons
|
||||||
*
|
*
|
||||||
|
|
|
@ -1674,7 +1674,7 @@ class FormHelper extends AppHelper {
|
||||||
$hidden = $this->hidden($fieldName, array(
|
$hidden = $this->hidden($fieldName, array(
|
||||||
'form' => isset($attributes['form']) ? $attributes['form'] : null,
|
'form' => isset($attributes['form']) ? $attributes['form'] : null,
|
||||||
'id' => $attributes['id'] . '_',
|
'id' => $attributes['id'] . '_',
|
||||||
'value' => '',
|
'value' => $hiddenField === true ? '' : $hiddenField,
|
||||||
'name' => $attributes['name']
|
'name' => $attributes['name']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue