diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 4eba64ff0..05042a154 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -121,6 +121,18 @@ class FormHelper extends AppHelper { $htmlAttributes['method'] = 'post'; break; } + + if (isset($options['default'])) { + if ($options['default'] == false) { + if (isset($htmlAttributes['onSubmit'])) { + $htmlAttributes['onSubmit'] .= ' return false;'; + } else { + $htmlAttributes['onSubmit'] = 'return false;'; + } + } + unset($options['default']); + } + $htmlAttributes['action'] = $this->url($options['action']); unset($options['type'], $options['action']); $htmlAttributes = am($options, $htmlAttributes); @@ -223,6 +235,24 @@ class FormHelper extends AppHelper { $this->setFormTag($tagName); + if (!isset($options['type']) || ($options['type'] == 'select' && !isset($options['options']))) { + if (ClassRegistry::isKeySet($this->model())) { + + $model =& ClassRegistry::getObject($this->model()); + if ($model->isForeignKey($this->field())) { + + $view =& ClassRegistry::getObject('view'); + $varName = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $this->field()))); + $varOptions = $view->getVar($varName); + + if (is_array($options)) { + $options['type'] = 'select'; + $options['options'] = $varOptions; + } + } + } + } + if (!isset($options['type'])) { $options['type'] = 'text';