fixing some changes to FormHelper

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4769 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-04-05 02:11:20 +00:00
parent aeac37e707
commit f49183f70e

View file

@ -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'];