Skip to content
Permalink
Browse files

Update FormHelper.php

An pull request for #4410.
  • Loading branch information...
MichalWadowski committed Aug 27, 2014
1 parent 0d518a1 commit a0017b5f1094409e4a32dc178c52d8b37e71b2ce
Showing with 37 additions and 5 deletions.
  1. +37 −5 src/View/Helper/FormHelper.php
@@ -908,9 +908,9 @@ public function input($fieldName, array $options = []) {
unset($options['error']);
}
$template = $options['type'] . 'Container' . $errorSuffix;
if (!$templater->get($template)) {
$template = 'inputContainer' . $errorSuffix;
$inputContainerTemplate = $options['type'] . 'Container' . $errorSuffix;
if (!$templater->get($inputContainerTemplate)) {
$inputContainerTemplate = 'inputContainer' . $errorSuffix;
}
$label = $options['label'];
@@ -929,12 +929,13 @@ public function input($fieldName, array $options = []) {
$label = $this->_getLabel($fieldName, compact('input', 'label', 'error') + $options);
$groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup';
$result = $templater->format($groupTemplate, compact('input', 'label', 'error'));
$result = $templater->format($template, [
$result = $this->_groupTemplate($groupTemplate, compact('input', 'label', 'error', 'options'));
$result = $this->_inputContainerTemplate($inputContainerTemplate, [
'content' => $result,
'error' => $error,
'required' => $options['required'] ? ' required' : '',
'type' => $options['type'],
'options' => $options
]);
if ($newTemplates) {
@@ -944,6 +945,37 @@ public function input($fieldName, array $options = []) {
return $result;
}
/**
* Generates an group template element
*
* @param string $groupTemplate the template name
* @param array $options The options for group template
* @return string The generated group template
*/
protected function _groupTemplate($groupTemplate, $options) {
return $this->templater()->format($groupTemplate, [
'input' => $options['input'],
'label' => $options['label'],
'error' => $options['error']
]);
}
/**
* Generates an input container template
*
* @param string $template the input container template name
* @param array $options The options for input container template
* @return string The generated input container template
*/
protected function _inputContainerTemplate($template, $options) {
return $this->templater()->format($template, [
'content' => $options['content'],
'error' => $options['error'],
'required' => $options['required'],
'type' => $options['type']
]);
}
/**
* Generates an input element
*

0 comments on commit a0017b5

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