From f49183f70ee9e3d4d80d30dcc61cb8b423284af9 Mon Sep 17 00:00:00 2001 From: gwoo Date: Thu, 5 Apr 2007 02:11:20 +0000 Subject: [PATCH] fixing some changes to FormHelper git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4769 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/form.php | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index abebc6246..84a54f2ca 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -109,7 +109,6 @@ class FormHelper extends AppHelper { $data = array( 'fields' => array_combine($fields->extract('{n}.name'), $fields->extract('{n}.type')), 'sizes' => array_combine($fields->extract('{n}.name'), $fields->extract('{n}.length')), - 'values' => array_combine($fields->extract('{n}.name'), $fields->extract('{n}.default')), 'key' => $object->primaryKey, 'validates' => (ife(empty($object->validate), array(), array_keys($object->validate))) ); @@ -331,7 +330,6 @@ class FormHelper extends AppHelper { if (!isset($options['type'])) { $options['type'] = 'text'; - if (isset($options['options'])) { $options['type'] = 'select'; } elseif (in_array($this->field(), array('passwd', 'password'))) { @@ -362,23 +360,12 @@ class FormHelper extends AppHelper { } } - if(!array_key_exists('size', $options)) { - if(isset($this->fieldset['sizes'][$this->field()])) { - $options['size'] = $this->fieldset['sizes'][$this->field()]; - } - } - if(!array_key_exists('maxlength', $options)) { + if(!array_key_exists('maxlength', $options) && $options['type'] == 'text') { if(isset($this->fieldset['sizes'][$this->field()])) { $options['maxlength'] = $this->fieldset['sizes'][$this->field()]; } } - if(!array_key_exists('value', $options)) { - if(isset($this->fieldset['values'][$this->field()])) { - $options['value'] = $this->fieldset['values'][$this->field()]; - } - } - $out = ''; $div = true; if (array_key_exists('div', $options)) { @@ -387,20 +374,17 @@ class FormHelper extends AppHelper { } if(!empty($div)) { - $divOptions = array(); - if ( !in_array($this->field(), $this->fieldset['validates'])) { - $divOptions['class'] = 'input'; - } elseif (in_array($this->field(), $this->fieldset['validates'])) { - $divOptions['class'] = 'required'; - } - + $divOptions = array('class'=>'input'); if (is_string($div)) { $divOptions['class'] = $div; } elseif (is_array($div)) { $divOptions = am($divOptions, $div); } + if (in_array($this->field(), $this->fieldset['validates'])) { + $divOptions = $this->addClass($divOptions, 'required'); + } } - + $label = null; if (isset($options['label'])) { $label = $options['label'];