mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding 'before', 'between', and 'after' options to FormHelper::input()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4298 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6dcdad1a2c
commit
6e56e926e7
1 changed files with 26 additions and 18 deletions
|
@ -261,6 +261,13 @@ class FormHelper extends AppHelper {
|
|||
function input($tagName, $options = array()) {
|
||||
|
||||
$this->setFormTag($tagName);
|
||||
$options = am(
|
||||
array(
|
||||
'before' => null,
|
||||
'between' => null,
|
||||
'after' => null
|
||||
),
|
||||
$options);
|
||||
|
||||
if ((!isset($options['type']) || $options['type'] == 'select') && !isset($options['options'])) {
|
||||
if (ClassRegistry::isKeySet($this->model())) {
|
||||
|
@ -364,7 +371,10 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$type = $options['type'];
|
||||
unset($options['type']);
|
||||
$before = $options['before'];
|
||||
$between = $options['between'];
|
||||
$after = $options['after'];
|
||||
unset($options['type'], $options['before'], $options['between'], $options['after']);
|
||||
|
||||
switch ($type) {
|
||||
case 'hidden':
|
||||
|
@ -372,44 +382,42 @@ class FormHelper extends AppHelper {
|
|||
unset($divOptions);
|
||||
break;
|
||||
case 'checkbox':
|
||||
$out = $this->Html->checkbox($tagName, null, $options) . $out;
|
||||
$out = $before . $this->Html->checkbox($tagName, null, $options) . $between . $out;
|
||||
break;
|
||||
case 'text':
|
||||
$out .= $this->text($tagName, $options);
|
||||
break;
|
||||
case 'password':
|
||||
$out .= $this->password($tagName, $options);
|
||||
$out = $before . $out . $between . $this->{$type}($tagName, $options);
|
||||
break;
|
||||
case 'file':
|
||||
$out .= $this->Html->file($tagName);
|
||||
$out = $before . $out . $between . $this->Html->file($tagName);
|
||||
break;
|
||||
case 'select':
|
||||
$list = array();
|
||||
if(isset($options['options'])) {
|
||||
$options = am(array('list' => array()), $options);
|
||||
$list = $options['options'];
|
||||
unset($options['options']);
|
||||
}
|
||||
$out .= $this->select($tagName, $list, $selected, $options, $empty);
|
||||
$out = $before . $out . $between . $this->select($tagName, $list, $selected, $options, $empty);
|
||||
break;
|
||||
case 'time':
|
||||
$out .= $this->Html->dateTimeOptionTag($tagName, null, '12', $selected, $options, null, $empty);
|
||||
$out = $before . $out . $between . $this->Html->dateTimeOptionTag($tagName, null, '12', $selected, $options, null, $empty);
|
||||
break;
|
||||
case 'date':
|
||||
$out .= $this->Html->dateTimeOptionTag($tagName, 'MDY', null, $selected, $options, null, $empty);
|
||||
$out = $before . $out . $between . $this->Html->dateTimeOptionTag($tagName, 'MDY', null, $selected, $options, null, $empty);
|
||||
break;
|
||||
case 'datetime':
|
||||
$out .= $this->Html->dateTimeOptionTag($tagName, 'MDY', '12', $selected, $options, null, $empty);
|
||||
$out = $before . $out . $between . $this->Html->dateTimeOptionTag($tagName, 'MDY', '12', $selected, $options, null, $empty);
|
||||
break;
|
||||
case 'textarea':
|
||||
default:
|
||||
$out .= $this->textarea($tagName, am(array('cols' => '30', 'rows' => '10'), $options));
|
||||
$out = $before . $out . $between . $this->textarea($tagName, am(array('cols' => '30', 'rows' => '10'), $options));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($error != null) {
|
||||
$out .= $this->Html->tagErrorMsg($tagName, $error);
|
||||
}
|
||||
|
||||
if ($type != 'hidden') {
|
||||
$out .= $after;
|
||||
}
|
||||
if (isset($divOptions)) {
|
||||
$out = $this->Html->div($divOptions['class'], $out, $divOptions);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue