mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Merge pull request #1674 from dereuromark/master-disabled-radio
Resolves ticket #4100
This commit is contained in:
commit
f7a7e27206
2 changed files with 35 additions and 1 deletions
|
@ -3978,6 +3978,40 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Model.field', array(
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
1 => 'A',
|
||||
2 => 'B',
|
||||
3 => 'C'
|
||||
),
|
||||
'disabled' => array(1)
|
||||
));
|
||||
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input radio'),
|
||||
'fieldset' => array(),
|
||||
'legend' => array(),
|
||||
'Field',
|
||||
'/legend',
|
||||
array('input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'id' => 'ModelField_', 'value' => '')),
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField1', 'disabled' => 'disabled', 'value' => '1')),
|
||||
array('label' => array('for' => 'ModelField1')),
|
||||
'A',
|
||||
'/label',
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField2', 'value' => '2')),
|
||||
array('label' => array('for' => 'ModelField2')),
|
||||
'B',
|
||||
'/label',
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField3', 'value' => '3')),
|
||||
array('label' => array('for' => 'ModelField3')),
|
||||
'C',
|
||||
'/label',
|
||||
'/fieldset',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1506,7 +1506,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
foreach ($options as $optValue => $optTitle) {
|
||||
$optionsHere = array('value' => $optValue);
|
||||
$optionsHere = array('value' => $optValue, 'disabled' => false);
|
||||
|
||||
if (isset($value) && strval($optValue) === strval($value)) {
|
||||
$optionsHere['checked'] = 'checked';
|
||||
|
|
Loading…
Add table
Reference in a new issue