mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-05-19 22:13:27 +00:00
starting refactor Form->input
This commit is contained in:
parent
b1aa75bec0
commit
a15481bbe9
2 changed files with 280 additions and 205 deletions
lib/Cake
|
@ -6117,7 +6117,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'label' => 'Current Text', 'value' => "GREAT®", 'rows' => '15', 'cols' => '75'
|
'label' => 'Current Text', 'value' => "GREAT®", 'rows' => '15', 'cols' => '75'
|
||||||
));
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('class' => 'input text'),
|
'div' => array('class' => 'input textarea'),
|
||||||
'label' => array('for' => 'PostContent'),
|
'label' => array('for' => 'PostContent'),
|
||||||
'Current Text',
|
'Current Text',
|
||||||
'/label',
|
'/label',
|
||||||
|
|
|
@ -944,88 +944,275 @@ class FormHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
public function input($fieldName, $options = array()) {
|
public function input($fieldName, $options = array()) {
|
||||||
$this->setEntity($fieldName);
|
$this->setEntity($fieldName);
|
||||||
|
$options = $this->_parseOptions($fieldName, $options);
|
||||||
|
|
||||||
|
$divOptions = $this->_divOptions($options);
|
||||||
|
unset($options['div']);
|
||||||
|
|
||||||
|
if ($options['type'] === 'radio' && isset($options['options'])) {
|
||||||
|
$radioOptions = (array)$options['options'];
|
||||||
|
unset($options['options']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = $this->_getLabel($fieldName, $options);
|
||||||
|
if ($options['type'] !== 'radio') {
|
||||||
|
unset($options['label']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = $this->_extractOption('error', $options, null);
|
||||||
|
unset($options['error']);
|
||||||
|
|
||||||
|
$errorMessage = $this->_extractOption('errorMessage', $options, true);
|
||||||
|
unset($options['errorMessage']);
|
||||||
|
|
||||||
|
$selected = $this->_extractOption('selected', $options, null);
|
||||||
|
unset($options['selected']);
|
||||||
|
|
||||||
|
if ($options['type'] === 'datetime' || $options['type'] === 'date' || $options['type'] === 'time') {
|
||||||
|
$dateFormat = $this->_extractOption('dateFormat', $options, 'MDY');
|
||||||
|
$timeFormat = $this->_extractOption('timeFormat', $options, 12);
|
||||||
|
unset($options['dateFormat'], $options['timeFormat']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $options['type'];
|
||||||
|
$out = array('before' => $options['before'], 'label' => $label, 'between' => $options['between'], 'after' => $options['after']);
|
||||||
|
$format = $this->_getFormat($options);
|
||||||
|
|
||||||
|
unset($options['type'], $options['before'], $options['between'], $options['after'], $options['format']);
|
||||||
|
|
||||||
|
$out['error'] = null;
|
||||||
|
if ($type != 'hidden' && $error !== false) {
|
||||||
|
$errMsg = $this->error($fieldName, $error);
|
||||||
|
if ($errMsg) {
|
||||||
|
$divOptions = $this->addClass($divOptions, 'error');
|
||||||
|
if ($errorMessage) {
|
||||||
|
$out['error'] = $errMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type === 'radio' && isset($out['between'])) {
|
||||||
|
$options['between'] = $out['between'];
|
||||||
|
$out['between'] = null;
|
||||||
|
}
|
||||||
|
$out['input'] = $this->_getInput(compact('type', 'fieldName', 'options', 'radioOptions', 'selected', 'dateFormat', 'timeFormat'));
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
foreach ($format as $element) {
|
||||||
|
$output .= $out[$element];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($divOptions['tag'])) {
|
||||||
|
$tag = $divOptions['tag'];
|
||||||
|
unset($divOptions['tag']);
|
||||||
|
$output = $this->Html->tag($tag, $output, $divOptions);
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $args
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
protected function _getInput($args) {
|
||||||
|
extract($args);
|
||||||
|
switch ($type) {
|
||||||
|
case 'hidden':
|
||||||
|
return $this->hidden($fieldName, $options);
|
||||||
|
case 'checkbox':
|
||||||
|
return $this->checkbox($fieldName, $options);
|
||||||
|
case 'radio':
|
||||||
|
return $this->radio($fieldName, $radioOptions, $options);
|
||||||
|
case 'file':
|
||||||
|
return $this->file($fieldName, $options);
|
||||||
|
case 'select':
|
||||||
|
$options += array('options' => array(), 'value' => $selected);
|
||||||
|
$list = $options['options'];
|
||||||
|
unset($options['options']);
|
||||||
|
return $this->select($fieldName, $list, $options);
|
||||||
|
case 'time':
|
||||||
|
$options['value'] = $selected;
|
||||||
|
return $this->dateTime($fieldName, null, $timeFormat, $options);
|
||||||
|
case 'date':
|
||||||
|
$options['value'] = $selected;
|
||||||
|
return $this->dateTime($fieldName, $dateFormat, null, $options);
|
||||||
|
case 'datetime':
|
||||||
|
$options['value'] = $selected;
|
||||||
|
return $this->dateTime($fieldName, $dateFormat, $timeFormat, $options);
|
||||||
|
case 'textarea':
|
||||||
|
return $this->textarea($fieldName, $options + array('cols' => '30', 'rows' => '6'));
|
||||||
|
case 'url':
|
||||||
|
return $this->text($fieldName, array('type' => 'url') + $options);
|
||||||
|
default:
|
||||||
|
return $this->{$type}($fieldName, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $fieldName
|
||||||
|
* @param type $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _parseOptions($fieldName, $options) {
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
array('before' => null, 'between' => null, 'after' => null, 'format' => null),
|
array('before' => null, 'between' => null, 'after' => null, 'format' => null),
|
||||||
$this->_inputDefaults,
|
$this->_inputDefaults,
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isset($options['type'])) {
|
||||||
|
$options = $this->_magicOptions($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($options['type'], array('checkbox', 'radio', 'select'))) {
|
||||||
|
$options = $this->_optionsOptions($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['rows']) || isset($options['cols'])) {
|
||||||
|
$options['type'] = 'textarea';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($options['type'] === 'datetime' || $options['type'] === 'date' || $options['type'] === 'time' || $options['type'] === 'select') {
|
||||||
|
$options += array('empty' => false);
|
||||||
|
}
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _optionsOptions($options) {
|
||||||
|
if (isset($options['options'])) {
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
$varName = Inflector::variable(
|
||||||
|
Inflector::pluralize(preg_replace('/_id$/', '', $this->field()))
|
||||||
|
);
|
||||||
|
$varOptions = $this->_View->getVar($varName);
|
||||||
|
if (!is_array($varOptions)) {
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
if ($options['type'] !== 'radio') {
|
||||||
|
$options['type'] = 'select';
|
||||||
|
}
|
||||||
|
$options['options'] = $varOptions;
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _magicOptions($options) {
|
||||||
$modelKey = $this->model();
|
$modelKey = $this->model();
|
||||||
$fieldKey = $this->field();
|
$fieldKey = $this->field();
|
||||||
|
$options['type'] = 'text';
|
||||||
if (!isset($options['type'])) {
|
if (isset($options['options'])) {
|
||||||
$magicType = true;
|
$options['type'] = 'select';
|
||||||
$options['type'] = 'text';
|
} elseif (in_array($fieldKey, array('psword', 'passwd', 'password'))) {
|
||||||
if (isset($options['options'])) {
|
$options['type'] = 'password';
|
||||||
$options['type'] = 'select';
|
} elseif (isset($options['checked'])) {
|
||||||
} elseif (in_array($fieldKey, array('psword', 'passwd', 'password'))) {
|
$options['type'] = 'checkbox';
|
||||||
$options['type'] = 'password';
|
} elseif ($fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey)) {
|
||||||
} elseif (isset($options['checked'])) {
|
$type = $fieldDef['type'];
|
||||||
$options['type'] = 'checkbox';
|
$primaryKey = $this->fieldset[$modelKey]['key'];
|
||||||
} elseif ($fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey)) {
|
$map = array(
|
||||||
$type = $fieldDef['type'];
|
'string' => 'text', 'datetime' => 'datetime',
|
||||||
$primaryKey = $this->fieldset[$modelKey]['key'];
|
'boolean' => 'checkbox', 'timestamp' => 'datetime',
|
||||||
}
|
'text' => 'textarea', 'time' => 'time',
|
||||||
|
'date' => 'date', 'float' => 'number',
|
||||||
if (isset($type)) {
|
'integer' => 'number'
|
||||||
$map = array(
|
|
||||||
'string' => 'text', 'datetime' => 'datetime',
|
|
||||||
'boolean' => 'checkbox', 'timestamp' => 'datetime',
|
|
||||||
'text' => 'textarea', 'time' => 'time',
|
|
||||||
'date' => 'date', 'float' => 'number',
|
|
||||||
'integer' => 'number'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($this->map[$type])) {
|
|
||||||
$options['type'] = $this->map[$type];
|
|
||||||
} elseif (isset($map[$type])) {
|
|
||||||
$options['type'] = $map[$type];
|
|
||||||
}
|
|
||||||
if ($fieldKey == $primaryKey) {
|
|
||||||
$options['type'] = 'hidden';
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
$options['type'] === 'number' &&
|
|
||||||
$type === 'float' &&
|
|
||||||
!isset($options['step'])
|
|
||||||
) {
|
|
||||||
$options['step'] = 'any';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
|
|
||||||
$options['type'] = 'select';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($modelKey === $fieldKey) {
|
|
||||||
$options['type'] = 'select';
|
|
||||||
if (!isset($options['multiple'])) {
|
|
||||||
$options['multiple'] = 'multiple';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$types = array('checkbox', 'radio', 'select');
|
|
||||||
|
|
||||||
if (
|
|
||||||
(!isset($options['options']) && in_array($options['type'], $types)) ||
|
|
||||||
(isset($magicType) && in_array($options['type'], array('text', 'number')))
|
|
||||||
) {
|
|
||||||
$varName = Inflector::variable(
|
|
||||||
Inflector::pluralize(preg_replace('/_id$/', '', $fieldKey))
|
|
||||||
);
|
);
|
||||||
$varOptions = $this->_View->getVar($varName);
|
|
||||||
if (is_array($varOptions)) {
|
|
||||||
if ($options['type'] !== 'radio') {
|
|
||||||
$options['type'] = 'select';
|
|
||||||
}
|
|
||||||
$options['options'] = $varOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($options['type'] === 'select' && array_key_exists('step', $options)) {
|
if (isset($this->map[$type])) {
|
||||||
unset($options['step']);
|
$options['type'] = $this->map[$type];
|
||||||
|
} elseif (isset($map[$type])) {
|
||||||
|
$options['type'] = $map[$type];
|
||||||
|
}
|
||||||
|
if ($fieldKey == $primaryKey) {
|
||||||
|
$options['type'] = 'hidden';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
$options['type'] === 'number' &&
|
||||||
|
$type === 'float' &&
|
||||||
|
!isset($options['step'])
|
||||||
|
) {
|
||||||
|
$options['step'] = 'any';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
|
||||||
|
$options['type'] = 'select';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($modelKey === $fieldKey) {
|
||||||
|
$options['type'] = 'select';
|
||||||
|
if (!isset($options['multiple'])) {
|
||||||
|
$options['multiple'] = 'multiple';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in_array($options['type'], array('text', 'number'))) {
|
||||||
|
$options = $this->_optionsOptions($options);
|
||||||
|
}
|
||||||
|
if ($options['type'] === 'select' && array_key_exists('step', $options)) {
|
||||||
|
unset($options['step']);
|
||||||
|
}
|
||||||
|
$options = $this->_maxLength($options);
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _getFormat($options) {
|
||||||
|
if ($options['type'] == 'hidden') {
|
||||||
|
return array('input');
|
||||||
|
}
|
||||||
|
if (is_array($options['format']) && in_array('input', $options['format'])) {
|
||||||
|
return $options['format'];
|
||||||
|
}
|
||||||
|
if ($options['type'] == 'checkbox') {
|
||||||
|
return array('before', 'input', 'between', 'label', 'after', 'error');
|
||||||
|
}
|
||||||
|
return array('before', 'label', 'between', 'input', 'after', 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $fieldName
|
||||||
|
* @param type $options
|
||||||
|
* @return boolean|string false or Generated label element
|
||||||
|
*/
|
||||||
|
protected function _getLabel($fieldName, $options) {
|
||||||
|
if ($options['type'] === 'radio') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = null;
|
||||||
|
if (isset($options['label'])) {
|
||||||
|
$label = $options['label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($label === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->_inputLabel($fieldName, $label, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _maxLength($options) {
|
||||||
|
$fieldDef = $this->_introspectModel($this->model(), 'fields', $this->field());
|
||||||
$autoLength = (
|
$autoLength = (
|
||||||
!array_key_exists('maxlength', $options) &&
|
!array_key_exists('maxlength', $options) &&
|
||||||
isset($fieldDef['length']) &&
|
isset($fieldDef['length']) &&
|
||||||
|
@ -1038,150 +1225,38 @@ class FormHelper extends AppHelper {
|
||||||
if ($autoLength && $fieldDef['type'] == 'float') {
|
if ($autoLength && $fieldDef['type'] == 'float') {
|
||||||
$options['maxlength'] = array_sum(explode(',', $fieldDef['length'])) + 1;
|
$options['maxlength'] = array_sum(explode(',', $fieldDef['length'])) + 1;
|
||||||
}
|
}
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
$divOptions = array();
|
/**
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _divOptions($options) {
|
||||||
|
if ($options['type'] === 'hidden') {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
$div = $this->_extractOption('div', $options, true);
|
$div = $this->_extractOption('div', $options, true);
|
||||||
unset($options['div']);
|
if (!$div) {
|
||||||
|
return array();
|
||||||
if (!empty($div)) {
|
|
||||||
$divOptions['class'] = 'input';
|
|
||||||
$divOptions = $this->addClass($divOptions, $options['type']);
|
|
||||||
if (is_string($div)) {
|
|
||||||
$divOptions['class'] = $div;
|
|
||||||
} elseif (is_array($div)) {
|
|
||||||
$divOptions = array_merge($divOptions, $div);
|
|
||||||
}
|
|
||||||
if ($this->_introspectModel($modelKey, 'validates', $fieldKey)) {
|
|
||||||
$divOptions = $this->addClass($divOptions, 'required');
|
|
||||||
}
|
|
||||||
if (!isset($divOptions['tag'])) {
|
|
||||||
$divOptions['tag'] = 'div';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$label = null;
|
$divOptions = array('class' => 'input');
|
||||||
if (isset($options['label']) && $options['type'] !== 'radio') {
|
$divOptions = $this->addClass($divOptions, $options['type']);
|
||||||
$label = $options['label'];
|
if (is_string($div)) {
|
||||||
unset($options['label']);
|
$divOptions['class'] = $div;
|
||||||
|
} elseif (is_array($div)) {
|
||||||
|
$divOptions = array_merge($divOptions, $div);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($options['type'] === 'radio') {
|
if ($this->_introspectModel($this->model(), 'validates', $this->field())) {
|
||||||
$label = false;
|
$divOptions = $this->addClass($divOptions, 'required');
|
||||||
if (isset($options['options'])) {
|
|
||||||
$radioOptions = (array)$options['options'];
|
|
||||||
unset($options['options']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!isset($divOptions['tag'])) {
|
||||||
if ($label !== false) {
|
$divOptions['tag'] = 'div';
|
||||||
$label = $this->_inputLabel($fieldName, $label, $options);
|
|
||||||
}
|
}
|
||||||
|
return $divOptions;
|
||||||
$error = $this->_extractOption('error', $options, null);
|
|
||||||
unset($options['error']);
|
|
||||||
|
|
||||||
$errorMessage = $this->_extractOption('errorMessage', $options, true);
|
|
||||||
unset($options['errorMessage']);
|
|
||||||
|
|
||||||
$selected = $this->_extractOption('selected', $options, null);
|
|
||||||
unset($options['selected']);
|
|
||||||
|
|
||||||
if (isset($options['rows']) || isset($options['cols'])) {
|
|
||||||
$options['type'] = 'textarea';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($options['type'] === 'datetime' || $options['type'] === 'date' || $options['type'] === 'time' || $options['type'] === 'select') {
|
|
||||||
$options += array('empty' => false);
|
|
||||||
}
|
|
||||||
if ($options['type'] === 'datetime' || $options['type'] === 'date' || $options['type'] === 'time') {
|
|
||||||
$dateFormat = $this->_extractOption('dateFormat', $options, 'MDY');
|
|
||||||
$timeFormat = $this->_extractOption('timeFormat', $options, 12);
|
|
||||||
unset($options['dateFormat'], $options['timeFormat']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = $options['type'];
|
|
||||||
$out = array_merge(
|
|
||||||
array('before' => null, 'label' => null, 'between' => null, 'input' => null, 'after' => null, 'error' => null),
|
|
||||||
array('before' => $options['before'], 'label' => $label, 'between' => $options['between'], 'after' => $options['after'])
|
|
||||||
);
|
|
||||||
$format = null;
|
|
||||||
if (is_array($options['format']) && in_array('input', $options['format'])) {
|
|
||||||
$format = $options['format'];
|
|
||||||
}
|
|
||||||
unset($options['type'], $options['before'], $options['between'], $options['after'], $options['format']);
|
|
||||||
|
|
||||||
switch ($type) {
|
|
||||||
case 'hidden':
|
|
||||||
$input = $this->hidden($fieldName, $options);
|
|
||||||
$format = array('input');
|
|
||||||
unset($divOptions);
|
|
||||||
break;
|
|
||||||
case 'checkbox':
|
|
||||||
$input = $this->checkbox($fieldName, $options);
|
|
||||||
$format = $format ? $format : array('before', 'input', 'between', 'label', 'after', 'error');
|
|
||||||
break;
|
|
||||||
case 'radio':
|
|
||||||
if (isset($out['between'])) {
|
|
||||||
$options['between'] = $out['between'];
|
|
||||||
$out['between'] = null;
|
|
||||||
}
|
|
||||||
$input = $this->radio($fieldName, $radioOptions, $options);
|
|
||||||
break;
|
|
||||||
case 'file':
|
|
||||||
$input = $this->file($fieldName, $options);
|
|
||||||
break;
|
|
||||||
case 'select':
|
|
||||||
$options += array('options' => array(), 'value' => $selected);
|
|
||||||
$list = $options['options'];
|
|
||||||
unset($options['options']);
|
|
||||||
$input = $this->select($fieldName, $list, $options);
|
|
||||||
break;
|
|
||||||
case 'time':
|
|
||||||
$options['value'] = $selected;
|
|
||||||
$input = $this->dateTime($fieldName, null, $timeFormat, $options);
|
|
||||||
break;
|
|
||||||
case 'date':
|
|
||||||
$options['value'] = $selected;
|
|
||||||
$input = $this->dateTime($fieldName, $dateFormat, null, $options);
|
|
||||||
break;
|
|
||||||
case 'datetime':
|
|
||||||
$options['value'] = $selected;
|
|
||||||
$input = $this->dateTime($fieldName, $dateFormat, $timeFormat, $options);
|
|
||||||
break;
|
|
||||||
case 'textarea':
|
|
||||||
$input = $this->textarea($fieldName, $options + array('cols' => '30', 'rows' => '6'));
|
|
||||||
break;
|
|
||||||
case 'url':
|
|
||||||
$input = $this->text($fieldName, array('type' => 'url') + $options);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$input = $this->{$type}($fieldName, $options);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type != 'hidden' && $error !== false) {
|
|
||||||
$errMsg = $this->error($fieldName, $error);
|
|
||||||
if ($errMsg) {
|
|
||||||
$divOptions = $this->addClass($divOptions, 'error');
|
|
||||||
if ($errorMessage) {
|
|
||||||
$out['error'] = $errMsg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$out['input'] = $input;
|
|
||||||
$format = $format ? $format : array('before', 'label', 'between', 'input', 'after', 'error');
|
|
||||||
$output = '';
|
|
||||||
foreach ($format as $element) {
|
|
||||||
$output .= $out[$element];
|
|
||||||
unset($out[$element]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($divOptions['tag'])) {
|
|
||||||
$tag = $divOptions['tag'];
|
|
||||||
unset($divOptions['tag']);
|
|
||||||
$output = $this->Html->tag($tag, $output, $divOptions);
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue