mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Coding standards cleanup.
Fix coding standards Simplify addition of empty. Add doc block for new feature.
This commit is contained in:
parent
613e3824e0
commit
38b7ae3c67
2 changed files with 19 additions and 29 deletions
|
@ -3558,15 +3558,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRadioAddEmptyOption() {
|
||||
|
||||
// $options['empty'] = true
|
||||
$result = $this->Form->input('Model.1.field', array(
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => true,
|
||||
'hiddenField' => false
|
||||
)
|
||||
);
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => true,
|
||||
'hiddenField' => false
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input radio'),
|
||||
'fieldset' => array(),
|
||||
|
@ -3586,14 +3583,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
// $options['empty'] = 'CustomEmptyLabel'
|
||||
$result = $this->Form->input('Model.1.field', array(
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => 'CustomEmptyLabel',
|
||||
'hiddenField' => false
|
||||
)
|
||||
);
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => 'CustomEmptyLabel',
|
||||
'hiddenField' => false
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input radio'),
|
||||
'fieldset' => array(),
|
||||
|
@ -3613,16 +3608,13 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
// $options['empty'] = false
|
||||
$result = $this->Form->input('Model.1.field', array(
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => false,
|
||||
'hiddenField' => false
|
||||
)
|
||||
);
|
||||
'type' => 'radio',
|
||||
'options' => array('option A'),
|
||||
'empty' => false,
|
||||
'hiddenField' => false
|
||||
));
|
||||
$this->assertTextNotContains('"Model1Field"', $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1343,6 +1343,8 @@ class FormHelper extends AppHelper {
|
|||
* - `hiddenField` - boolean to indicate if you want the results of radio() to include
|
||||
* a hidden input with a value of ''. This is useful for creating radio sets that non-continuous
|
||||
* - `disabled` - Set to `true` or `disabled` to disable all the radio buttons.
|
||||
* - `empty` - Set to `true` to create a input with the value '' as the first option. When `true`
|
||||
* the radio label will be 'empty'. Set this option to a string to control the label value.
|
||||
*
|
||||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Radio button options array.
|
||||
|
@ -1356,9 +1358,7 @@ class FormHelper extends AppHelper {
|
|||
$showEmpty = $this->_extractOption('empty', $attributes);
|
||||
if ($showEmpty) {
|
||||
$showEmpty = ($showEmpty === true) ? __('empty') : $showEmpty;
|
||||
$options = array_reverse($options, true);
|
||||
$options[''] = $showEmpty;
|
||||
$options = array_reverse($options, true);
|
||||
$options = array('' => $showEmpty) + $options;
|
||||
}
|
||||
unset($attributes['empty']);
|
||||
|
||||
|
@ -1894,9 +1894,7 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if ($emptyMulti) {
|
||||
$showEmpty = ($showEmpty === true) ? '' : $showEmpty;
|
||||
$options = array_reverse($options, true);
|
||||
$options[''] = $showEmpty;
|
||||
$options = array_reverse($options, true);
|
||||
$options = array('' => $showEmpty) + $options;
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
|
|
Loading…
Reference in a new issue