Merge pull request #157 from ProLoser/patch-2

Added `'integer' => 'number'` for HTML5
This commit is contained in:
Mark Story 2011-08-01 18:07:40 -07:00
commit 4da671c952
2 changed files with 34 additions and 2 deletions

View file

@ -97,7 +97,8 @@ class Contact extends CakeTestModel {
'password' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), 'password' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null), 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null),
'age' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => null)
); );
/** /**
@ -887,6 +888,36 @@ class FormHelperTest extends CakeTestCase {
); );
} }
/**
* Tests correct generation of text fields for double and float fields
*
* @access public
* @return void
*/
public function testTextFieldTypeNumberGenerationForIntegers() {
$model = ClassRegistry::getObject('Contact');
$model->setSchema(array('foo' => array(
'type' => 'integer',
'null' => false,
'default' => null,
'length' => null
)));
$this->Form->create('Contact');
$result = $this->Form->input('foo');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactFoo'),
'Foo',
'/label',
array('input' => array(
'type' => 'number', 'name' => 'data[Contact][foo]',
'id' => 'ContactFoo'
)),
'/div'
);
}
/** /**
* testFormSecurityMultipleFields method * testFormSecurityMultipleFields method
* *

View file

@ -917,7 +917,8 @@ class FormHelper extends AppHelper {
'string' => 'text', 'datetime' => 'datetime', 'string' => 'text', 'datetime' => 'datetime',
'boolean' => 'checkbox', 'timestamp' => 'datetime', 'boolean' => 'checkbox', 'timestamp' => 'datetime',
'text' => 'textarea', 'time' => 'time', 'text' => 'textarea', 'time' => 'time',
'date' => 'date', 'float' => 'text' 'date' => 'date', 'float' => 'number',
'integer' => 'number'
); );
if (isset($this->map[$type])) { if (isset($this->map[$type])) {