Fix that hidden elements are getting ovewritten when validating a form
This works by "disabling" hidden elements which causes the browser not to submit them. Due to a bug in Zend we need to manually ensure that Form::isValid does not overwrite the value of disabled elements with null. fixes #7717
This commit is contained in:
parent
760bf1a020
commit
1cbdd2b51c
|
@ -66,7 +66,7 @@ class AutologinBackendForm extends Form
|
||||||
'hidden',
|
'hidden',
|
||||||
'backend',
|
'backend',
|
||||||
array(
|
array(
|
||||||
'required' => true,
|
'disabled' => true,
|
||||||
'value' => 'autologin'
|
'value' => 'autologin'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DbBackendForm extends Form
|
||||||
'hidden',
|
'hidden',
|
||||||
'backend',
|
'backend',
|
||||||
array(
|
array(
|
||||||
'required' => true,
|
'disabled' => true,
|
||||||
'value' => 'db'
|
'value' => 'db'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -96,7 +96,7 @@ class LdapBackendForm extends Form
|
||||||
'hidden',
|
'hidden',
|
||||||
'backend',
|
'backend',
|
||||||
array(
|
array(
|
||||||
'required' => true,
|
'disabled' => true,
|
||||||
'value' => 'ldap'
|
'value' => 'ldap'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -665,6 +665,14 @@ class Form extends Zend_Form
|
||||||
public function isValidPartial(array $formData)
|
public function isValidPartial(array $formData)
|
||||||
{
|
{
|
||||||
$this->create($formData);
|
$this->create($formData);
|
||||||
|
|
||||||
|
// Ensure that disabled elements are not overwritten (http://www.zendframework.com/issues/browse/ZF-6909)
|
||||||
|
foreach ($this->getElements() as $name => $element) {
|
||||||
|
if ($element->getAttrib('disabled')) {
|
||||||
|
$formData[$name] = $element->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return parent::isValidPartial($formData);
|
return parent::isValidPartial($formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,6 +686,14 @@ class Form extends Zend_Form
|
||||||
public function isValid($formData)
|
public function isValid($formData)
|
||||||
{
|
{
|
||||||
$this->create($formData);
|
$this->create($formData);
|
||||||
|
|
||||||
|
// Ensure that disabled elements are not overwritten (http://www.zendframework.com/issues/browse/ZF-6909)
|
||||||
|
foreach ($this->getElements() as $name => $element) {
|
||||||
|
if ($element->getAttrib('disabled')) {
|
||||||
|
$formData[$name] = $element->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return parent::isValid($formData);
|
return parent::isValid($formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue