mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Adding automatic list variable detection for select menus, and 'default' => false option for preventing form submits via JavaScript
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4113 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
fd9a347fe1
commit
3c023b4335
1 changed files with 30 additions and 0 deletions
|
@ -121,6 +121,18 @@ class FormHelper extends AppHelper {
|
||||||
$htmlAttributes['method'] = 'post';
|
$htmlAttributes['method'] = 'post';
|
||||||
break;
|
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']);
|
$htmlAttributes['action'] = $this->url($options['action']);
|
||||||
unset($options['type'], $options['action']);
|
unset($options['type'], $options['action']);
|
||||||
$htmlAttributes = am($options, $htmlAttributes);
|
$htmlAttributes = am($options, $htmlAttributes);
|
||||||
|
@ -223,6 +235,24 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
$this->setFormTag($tagName);
|
$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'])) {
|
if (!isset($options['type'])) {
|
||||||
$options['type'] = 'text';
|
$options['type'] = 'text';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue