mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Don't disable the entire select when disabled is array(1)
When the disabled attribute is just array(1), then the attribute should be filtered out of select element attributes. This is kind of a hacky workaround but changing the underlying attribute handling is going to be pretty tricky and far more dangerous. Fixes #3546
This commit is contained in:
parent
81875cfeb1
commit
db86b0c050
2 changed files with 9 additions and 5 deletions
|
@ -4939,7 +4939,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
*/
|
||||
public function testSelectMultipleWithDisabledElements() {
|
||||
$options = array(1 => 'One', 2 => 'Two', '3' => 'Three', '3x' => 'Stringy');
|
||||
$disabled = array(2, 3);
|
||||
$disabled = array(1);
|
||||
$result = $this->Form->select('Contact.multiple', $options, array('multiple' => 'multiple', 'disabled' => $disabled));
|
||||
$expected = array(
|
||||
'input' => array(
|
||||
|
@ -4948,13 +4948,13 @@ class FormHelperTest extends CakeTestCase {
|
|||
'select' => array(
|
||||
'name' => 'data[Contact][multiple][]', 'multiple' => 'multiple', 'id' => 'ContactMultiple'
|
||||
),
|
||||
array('option' => array('value' => '1')),
|
||||
array('option' => array('value' => '1', 'disabled' => 'disabled')),
|
||||
'One',
|
||||
'/option',
|
||||
array('option' => array('value' => '2', 'disabled' => 'disabled')),
|
||||
array('option' => array('value' => '2')),
|
||||
'Two',
|
||||
'/option',
|
||||
array('option' => array('value' => '3', 'disabled' => 'disabled')),
|
||||
array('option' => array('value' => '3')),
|
||||
'Three',
|
||||
'/option',
|
||||
array('option' => array('value' => '3x')),
|
||||
|
|
|
@ -2091,7 +2091,11 @@ class FormHelper extends AppHelper {
|
|||
) {
|
||||
$this->_secure(true, $this->_secureFieldName($attributes));
|
||||
}
|
||||
$select[] = $this->Html->useTag($tag, $attributes['name'], array_diff_key($attributes, array('name' => null, 'value' => null)));
|
||||
$filter = array('name' => null, 'value' => null);
|
||||
if (is_array($attributes['disabled'])) {
|
||||
$filter['disabled'] = null;
|
||||
}
|
||||
$select[] = $this->Html->useTag($tag, $attributes['name'], array_diff_key($attributes, $filter));
|
||||
}
|
||||
$emptyMulti = (
|
||||
$showEmpty !== null && $showEmpty !== false && !(
|
||||
|
|
Loading…
Reference in a new issue