Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoring code to make it possible to nest a input inside a label

  • Loading branch information...
commit e5316ab8043eac134b90d3202e63859cd315762a 1 parent dfc7487
@lorenzo lorenzo authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 src/View/Helper/FormHelper.php
View
15 src/View/Helper/FormHelper.php
@@ -841,12 +841,6 @@ public function input($fieldName, $options = []) {
$this->templates($options['templates']);
unset($options['templates']);
- $label = $this->_getLabel($fieldName, $options);
-
- if ($options['type'] !== 'radio') {
- unset($options['label']);
- }
-
$template = 'groupContainer';
$error = null;
if ($options['type'] !== 'hidden' && $options['error'] !== false) {
@@ -855,8 +849,15 @@ public function input($fieldName, $options = []) {
unset($options['error']);
}
- $groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup';
+ $label = $options['label'];
+ if ($options['type'] !== 'radio') {
+ unset($options['label']);
+ }
+
$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'));
if ($options['type'] !== 'hidden') {
Please sign in to comment.
Something went wrong with that request. Please try again.