Skip to content
Permalink
Browse files

Removing text() and password() as the new __call method handles them.

Updating test cases and adding a test for allowing a magic method to override the type.
  • Loading branch information...
markstory committed Aug 17, 2010
1 parent 4efc170 commit 750fe3aa052957e9f0e834a6508d98bdaef6feba
Showing with 13 additions and 44 deletions.
  1. +6 −43 cake/libs/view/helpers/form.php
  2. +7 −1 cake/tests/cases/libs/view/helpers/form.test.php
@@ -861,10 +861,8 @@ public function input($fieldName, $options = array()) {
case 'radio':
$input = $this->radio($fieldName, $radioOptions, $options);
break;
case 'text':
case 'password':
case 'file':
$input = $this->{$type}($fieldName, $options);
$input = $this->file($fieldName, $options);
break;
case 'select':
$options += array('options' => array());
@@ -882,9 +880,10 @@ public function input($fieldName, $options = array()) {
$input = $this->dateTime($fieldName, $dateFormat, $timeFormat, $selected, $options);
break;
case 'textarea':
default:
$input = $this->textarea($fieldName, $options + array('cols' => '30', 'rows' => '6'));
break;
default:
$input = $this->{$type}($fieldName, $options);
}
if ($type != 'hidden' && $error !== false) {
@@ -1110,44 +1109,6 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
return $out;
}
/**
* Creates a text input widget.
*
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
* @param array $options Array of HTML attributes.
* @return string A generated HTML text input element
* @access public
* @link http://book.cakephp.org/view/1432/text
*/
public function text($fieldName, $options = array()) {
$options = $this->_initInputField($fieldName, array_merge(
array('type' => 'text'), $options
));
return sprintf(
$this->Html->tags['input'],
$options['name'],
$this->_parseAttributes($options, array('name'), null, ' ')
);
}
/**
* Creates a password input widget.
*
* @param string $fieldName Name of a field, like in the form "Modelname.fieldname"
* @param array $options Array of HTML attributes.
* @return string A generated password input.
* @access public
* @link http://book.cakephp.org/view/1428/password
*/
public function password($fieldName, $options = array()) {
$options = $this->_initInputField($fieldName, $options);
return sprintf(
$this->Html->tags['password'],
$options['name'],
$this->_parseAttributes($options, array('name'), null, ' ')
);
}
/**
* Missing method handler - implements various simple input types. Is used to create inputs
* of various types. e.g. `$this->Form->text();` will create `<input type="text" />` while
@@ -1176,7 +1137,9 @@ public function __call($method, $params) {
if (isset($params[1])) {
$options = $params[1];
}
$options['type'] = $method;
if (!isset($options['type'])) {
$options['type'] = $method;
}
$options = $this->_initInputField($params[0], $options);
return sprintf(
$this->Html->tags['input'],
@@ -6382,12 +6382,18 @@ function testHtml5Inputs() {
'input' => array('type' => 'search', 'name' => 'data[User][query]', 'id' => 'UserQuery')
);
$this->assertTags($result, $expected);
$result = $this->Form->search('User.query', array('value' => 'test'));
$expected = array(
'input' => array('type' => 'search', 'name' => 'data[User][query]', 'id' => 'UserQuery', 'value' => 'test')
);
$this->assertTags($result, $expected);
$result = $this->Form->search('User.query', array('type' => 'text', 'value' => 'test'));
$expected = array(
'input' => array('type' => 'text', 'name' => 'data[User][query]', 'id' => 'UserQuery', 'value' => 'test')
);
$this->assertTags($result, $expected);
}
/**

0 comments on commit 750fe3a

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