Skip to content
Permalink
Browse files

Changed how `label` is passed around, reduces the impact on many Widgets

  • Loading branch information...
lilHermit committed Jan 31, 2017
1 parent dcbb89f commit f304403be3fd27af40571343a235cdd22b248e0a
@@ -1134,22 +1134,24 @@ protected function _inputContainerTemplate($options)
*/
protected function _getInput($fieldName, $options)
{
$label = $options['label'];
unset($options['label']);
switch (strtolower($options['type'])) {
case 'select':
$opts = $options['options'];
unset($options['options']);
return $this->select($fieldName, $opts, $options);
return $this->select($fieldName, $opts, $options + ['label' => $label]);
case 'radio':
$opts = $options['options'];
unset($options['options']);
return $this->radio($fieldName, $opts, $options);
return $this->radio($fieldName, $opts, $options + ['label' => $label]);
case 'multicheckbox':
$opts = $options['options'];
unset($options['options']);
return $this->multiCheckbox($fieldName, $opts, $options);
return $this->multiCheckbox($fieldName, $opts, $options + ['label' => $label]);
case 'input':
throw new RuntimeException("Invalid type 'input' used for field '$fieldName'");
@@ -1934,6 +1936,8 @@ public function select($fieldName, $options = [], array $attributes = [])
return $this->multiCheckbox($fieldName, $options, $attributes);
}
unset($attributes['label']);
// Secure the field if there are options, or it's a multi select.
// Single selects with no options don't submit, but multiselects do.
if ($attributes['secure'] &&
@@ -76,7 +76,7 @@ public function render(array $data, ContextInterface $context)
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes(
$data,
['name', 'type', 'label']
['name', 'type']
),
]);
}
@@ -55,7 +55,7 @@ public function render(array $data, ContextInterface $context)
$attrs = $this->_templates->formatAttributes(
$data,
['name', 'value', 'label']
['name', 'value']
);
return $this->_templates->format('checkbox', [
@@ -65,7 +65,7 @@ public function render(array $data, ContextInterface $context)
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes(
$data,
['name', 'label']
['name']
)
]);
}
@@ -125,7 +125,7 @@ public function render(array $data, ContextInterface $context)
$template = 'selectMultiple';
unset($data['multiple']);
}
$attrs = $this->_templates->formatAttributes($data, ['label']);
$attrs = $this->_templates->formatAttributes($data);
return $this->_templates->format($template, [
'name' => $name,
@@ -55,7 +55,7 @@ public function render(array $data, ContextInterface $context)
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes(
$data,
['name', 'val', 'label']
['name', 'val']
)
]);
}
@@ -3325,8 +3325,7 @@ public function testInputDatetime()
'empty' => false,
'id' => 'prueba',
'required' => false,
'templateVars' => [],
'label' => true
'templateVars' => []
])
->will($this->returnValue('This is it!'));
$result = $this->Form->input('prueba', [
@@ -3371,8 +3370,7 @@ public function testInputDatetimeIdPrefix()
'empty' => false,
'id' => 'prefix-prueba',
'required' => false,
'templateVars' => [],
'label' => true
'templateVars' => []
])
->will($this->returnValue('This is it!'));
$result = $this->Form->input('prueba', [

0 comments on commit f304403

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