mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding field type interpreting to FormHelper::input()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3595 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8319e0ff30
commit
04a095d45a
1 changed files with 39 additions and 12 deletions
|
@ -128,9 +128,14 @@ class FormHelper extends Helper {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function input($tagName, $options = array()) {
|
function input($tagName, $options = array()) {
|
||||||
|
|
||||||
|
$this->setFormTag($tagName);
|
||||||
|
|
||||||
if (!isset($options['type'])) {
|
if (!isset($options['type'])) {
|
||||||
if (isset($options['options'])) {
|
if (isset($options['options'])) {
|
||||||
$options['type'] = 'select';
|
$options['type'] = 'select';
|
||||||
|
} elseif ($this->field() == 'passwd' || $this->field() == 'password') {
|
||||||
|
$options['type'] = 'password';
|
||||||
} else {
|
} else {
|
||||||
$options['type'] = 'text';
|
$options['type'] = 'text';
|
||||||
}
|
}
|
||||||
|
@ -166,6 +171,9 @@ class FormHelper extends Helper {
|
||||||
case 'text':
|
case 'text':
|
||||||
$out .= $this->text($tagName);
|
$out .= $this->text($tagName);
|
||||||
break;
|
break;
|
||||||
|
case 'password':
|
||||||
|
$out .= $this->password($tagName);
|
||||||
|
break;
|
||||||
case 'file':
|
case 'file':
|
||||||
$out .= $this->Html->file($tagName);
|
$out .= $this->Html->file($tagName);
|
||||||
break;
|
break;
|
||||||
|
@ -175,6 +183,10 @@ class FormHelper extends Helper {
|
||||||
unset($options['options'], $options['empty']);
|
unset($options['options'], $options['empty']);
|
||||||
$out .= $this->select($tagName, $list, null, $options, $empty);
|
$out .= $this->select($tagName, $list, null, $options, $empty);
|
||||||
break;
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
default:
|
||||||
|
$out .= $this->textarea($tagName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error != null) {
|
if ($error != null) {
|
||||||
|
@ -186,18 +198,6 @@ class FormHelper extends Helper {
|
||||||
}
|
}
|
||||||
return $this->output($out);
|
return $this->output($out);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function divTag($class, $text) {
|
|
||||||
return sprintf(TAG_DIV, $class, $text);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function pTag($class, $text) {
|
|
||||||
return sprintf(TAG_P_CLASS, $class, $text);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Creates a text input widget.
|
* Creates a text input widget.
|
||||||
*
|
*
|
||||||
|
@ -218,6 +218,21 @@ class FormHelper extends Helper {
|
||||||
}
|
}
|
||||||
return $this->output(sprintf($this->tags['input'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
|
return $this->output(sprintf($this->tags['input'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Creates a password input widget.
|
||||||
|
*
|
||||||
|
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
|
||||||
|
* @param array $htmlAttributes Array of HTML attributes.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function password($fieldName, $htmlAttributes = null) {
|
||||||
|
$htmlAttributes = $this->__value($htmlAttributes, $fieldName);
|
||||||
|
$htmlAttributes = $this->domId($htmlAttributes);
|
||||||
|
if ($this->tagIsInvalid()) {
|
||||||
|
$htmlAttributes = $this->addClass($htmlAttributes, 'form_error');
|
||||||
|
}
|
||||||
|
return $this->output(sprintf($this->tags['password'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a textarea widget.
|
* Creates a textarea widget.
|
||||||
*
|
*
|
||||||
|
@ -712,5 +727,17 @@ class FormHelper extends Helper {
|
||||||
}
|
}
|
||||||
return $strFormFields;
|
return $strFormFields;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function divTag($class, $text) {
|
||||||
|
return sprintf(TAG_DIV, $class, $text);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function pTag($class, $text) {
|
||||||
|
return sprintf(TAG_P_CLASS, $class, $text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue