Skip to content
Permalink
Browse files

Fixed phpcs issues

  • Loading branch information...
lilHermit committed Jan 30, 2017
1 parent 9a7b8cf commit 8ff6564d54b7161fd8fce37e3f660177f91be641
@@ -1053,7 +1053,7 @@ public function input($fieldName, array $options = [])
$options['hiddenField'] = '_split';
}
$input = $this->_getInput($fieldName, $options + [ 'label' => $optionsLabel] );
$input = $this->_getInput($fieldName, $options + ['label' => $optionsLabel]);
if ($options['type'] === 'hidden' || $options['type'] === 'submit') {
if ($newTemplates) {
$templater->pop();
@@ -200,22 +200,22 @@ protected function _renderInput($checkbox, $context)
$label = $input;
} else {
$labelAttrs = [
'for' => $checkbox['id'],
'escape' => $checkbox['escape'],
'text' => $checkbox['text'],
'templateVars' => $checkbox['templateVars'],
'input' => $input
];
'for' => $checkbox['id'],
'escape' => $checkbox['escape'],
'text' => $checkbox['text'],
'templateVars' => $checkbox['templateVars'],
'input' => $input
];
if(is_array($checkbox['label'])) {
if (is_array($checkbox['label'])) {
$labelAttrs += $checkbox['label'];
}
if (isset($checkbox['checked']) && $checkbox['checked']) {
if(isset($labelAttrs['class'])) {
if (isset($labelAttrs['class'])) {
if (is_array($labelAttrs['class'])) {
$labelAttrs['class'][] = 'selected';
} else if(is_string($labelAttrs['class'])) {
} elseif (is_string($labelAttrs['class'])) {
$labelAttrs['class'] .= ' selected';
}
} else {
@@ -225,6 +225,7 @@ protected function _renderInput($checkbox, $context)
$label = $this->_label->render($labelAttrs, $context);
}
return $this->_templates->format('checkboxWrapper', [
'templateVars' => $checkbox['templateVars'],
'label' => $label,
@@ -183,10 +183,10 @@ protected function _renderInput($val, $text, $data, $context)
$data['label']['class'] = [];
}
if (isset($radio['checked']) && $radio['checked']) {
if(isset($data['label']['class'])) {
if (isset($data['label']['class'])) {
if (is_array($data['label']['class'])) {
$data['label']['class'][] = 'selected';
} else if(is_string($data['label']['class'])) {
} elseif (is_string($data['label']['class'])) {
$data['label']['class'] .= ' selected';
}
} else {
@@ -8505,9 +8505,8 @@ public function testNestedLabelInput()
* Tests false, class (as string and array) also makes sure 'selected' is added to the class if checked.
* Also checks to make sure any custom attributes are rendered
*/
public function testControlLabelManipulator()
public function testControlLabelManipulation()
{
// Tests removal of label around input (Radio)
$result = $this->Form->input('test', [
'type' => 'radio',
@@ -8601,15 +8600,13 @@ public function testControlLabelManipulator()
$this->assertHtml($expected, $result);
// Tests class as array and adding selected as well as custom attributes (Radio)
$result = $this->Form->radio('test', ['A', 'B'],
[
'label' => [
'class' => ['custom-class', 'another-class'],
'some-other-attr' => 'blah'
],
'value' => 1
]
);
$result = $this->Form->radio('test', ['A', 'B'], [
'label' => [
'class' => ['custom-class', 'another-class'],
'some-other-attr' => 'blah'
],
'value' => 1
]);
$expected = [
'input' => ['type' => 'hidden', 'name' => 'test', 'value' => ''],
['label' => ['class' => 'custom-class another-class', 'some-other-attr' => 'blah', 'for' => 'test-0']],

0 comments on commit 8ff6564

Please sign in to comment.
You can’t perform that action at this time.