mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
Do not hard code the name of the form identification element
Like the csrf element name the form identification element name should be publicly accessible as well. refs #5525
This commit is contained in:
parent
6783d51f76
commit
e1329058db
@ -60,6 +60,13 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
protected $tokenElementName = 'CSRFToken';
|
protected $tokenElementName = 'CSRFToken';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the form identification element
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $uidElementName = 'formUID';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the label to use for the standard submit button
|
* Set the label to use for the standard submit button
|
||||||
*
|
*
|
||||||
@ -185,6 +192,29 @@ class Form extends Zend_Form
|
|||||||
return $this->tokenElementName;
|
return $this->tokenElementName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name to use for the form identification element
|
||||||
|
*
|
||||||
|
* @param string $name The name to set
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setUidElementName($name)
|
||||||
|
{
|
||||||
|
$this->uidElementName = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the form identification element
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUidElementName()
|
||||||
|
{
|
||||||
|
return $this->uidElementName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this form
|
* Create this form
|
||||||
*
|
*
|
||||||
@ -317,7 +347,7 @@ class Form extends Zend_Form
|
|||||||
{
|
{
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'hidden',
|
'hidden',
|
||||||
'form_uid',
|
$this->uidElementName,
|
||||||
array(
|
array(
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'value' => $this->getName()
|
'value' => $this->getName()
|
||||||
@ -416,7 +446,7 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
public function wasSent(array $formData)
|
public function wasSent(array $formData)
|
||||||
{
|
{
|
||||||
return isset($formData['form_uid']) && $formData['form_uid'] === $this->getName();
|
return isset($formData[$this->uidElementName]) && $formData[$this->uidElementName] === $this->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user