Permalink
Browse files

First FormHelper::input assertion passing

  • Loading branch information...
1 parent 0644544 commit f8695d253e4ef4f528803fb8cb6fbedb117c1528 @lorenzo lorenzo committed Feb 23, 2014
@@ -150,9 +150,7 @@ protected function _prepare() {
* @return boolean
*/
public function primaryKey() {
- $table = $this->_tables[$this->_rootName];
- $schema = $table->schema();
- return $schema->primaryKey();
+ return $this->_tables[$this->_rootName]->primaryKey();
}
/**
@@ -905,7 +905,7 @@ protected function _parseOptions($fieldName, $options) {
protected function _inputType($fieldName, $options) {
$context = $this->_getContext();
- $primaryKey = $context->primaryKey();
+ $primaryKey = (array)$context->primaryKey();
if (in_array($fieldName, $primaryKey)) {
return 'hidden';
@@ -971,7 +971,7 @@ protected function _optionsOptions($fieldName, $options) {
protected function _magicOptions($fieldName, $options, $allowOverride) {
$context = $this->_getContext();
$type = $context->type($fieldName);
- $fielDef = $context->attributes($fieldName);
+ $fieldDef = $context->attributes($fieldName);
if ($options['type'] === 'number' && !isset($options['step'])) {
if ($type === 'decimal') {
@@ -327,10 +327,20 @@ class ValidateUsersTable extends Table {
'ratio' => array('type' => 'decimal', 'null' => false, 'length' => '10,6'),
'population' => array('type' => 'decimal', 'null' => false, 'length' => '15,0'),
'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),
+ '_constraints' => array('primary' => ['type' => 'primary', 'columns' => ['id']])
);
/**
+ * Initializes the schema
+ *
+ * @return void
+ */
+ public function initialize(array $config) {
+ $this->schema($this->_schema);
+ }
+
+/**
* beforeValidate method
*
* @param array $options
@@ -2404,14 +2414,17 @@ public function testMultipleInputValidation() {
* @return void
*/
public function testInput() {
- $this->Form->create('ValidateUsers');
+ TableRegistry::get('ValidateUsers', [
+ 'className' => __NAMESPACE__ . '\ValidateUsersTable'
+ ]);
+ $this->Form->create([], ['context' => ['table' => 'ValidateUsers']]);
$result = $this->Form->input('ValidateUsers.balance');
$expected = array(
'div' => array('class'),
'label' => array('for'),
'Balance',
'/label',
- 'input' => array('name', 'type' => 'number', 'id'),
+ 'input' => array('name', 'type' => 'number', 'step'),
'/div',
);
$this->assertTags($result, $expected);

0 comments on commit f8695d2

Please sign in to comment.