Skip to content

Commit

Permalink
Refactoring code to make it possible to nest a input inside a label
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 7, 2014
1 parent dfc7487 commit e5316ab
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/View/Helper/FormHelper.php
Expand Up @@ -841,12 +841,6 @@ public function input($fieldName, $options = []) {
$this->templates($options['templates']); $this->templates($options['templates']);
unset($options['templates']); unset($options['templates']);


$label = $this->_getLabel($fieldName, $options);

if ($options['type'] !== 'radio') {
unset($options['label']);
}

$template = 'groupContainer'; $template = 'groupContainer';
$error = null; $error = null;
if ($options['type'] !== 'hidden' && $options['error'] !== false) { if ($options['type'] !== 'hidden' && $options['error'] !== false) {
Expand All @@ -855,8 +849,15 @@ public function input($fieldName, $options = []) {
unset($options['error']); unset($options['error']);
} }


$groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup'; $label = $options['label'];
if ($options['type'] !== 'radio') {
unset($options['label']);
}

$input = $this->_getInput($fieldName, $options); $input = $this->_getInput($fieldName, $options);
$label = $this->_getLabel($fieldName, compact('input', 'label') + $options);

$groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup';
$result = $this->formatTemplate($groupTemplate, compact('input', 'label')); $result = $this->formatTemplate($groupTemplate, compact('input', 'label'));


if ($options['type'] !== 'hidden') { if ($options['type'] !== 'hidden') {
Expand Down

0 comments on commit e5316ab

Please sign in to comment.