mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
parent
439d1895a7
commit
8846f17ae1
@ -67,6 +67,13 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
protected $tokenElementName = 'CSRFToken';
|
protected $tokenElementName = 'CSRFToken';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this form should add a UID element being used to distinct different forms posting to the same action
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $uidDisabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the form identification element
|
* Name of the form identification element
|
||||||
*
|
*
|
||||||
@ -236,6 +243,34 @@ class Form extends Zend_Form
|
|||||||
return $this->tokenElementName;
|
return $this->tokenElementName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable form identification and remove its field if already added
|
||||||
|
*
|
||||||
|
* @param bool $disabled Set true in order to disable identification for this form, otherwise false
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setUidDisabled($disabled = true)
|
||||||
|
{
|
||||||
|
$this->uidDisabled = (bool) $disabled;
|
||||||
|
|
||||||
|
if ($disabled && $this->getElement($this->uidElementName) !== null) {
|
||||||
|
$this->removeElement($this->uidElementName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether identification is disabled for this form
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUidDisabled()
|
||||||
|
{
|
||||||
|
return $this->uidDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name to use for the form identification element
|
* Set the name to use for the form identification element
|
||||||
*
|
*
|
||||||
@ -398,14 +433,16 @@ class Form extends Zend_Form
|
|||||||
*/
|
*/
|
||||||
public function addFormIdentification()
|
public function addFormIdentification()
|
||||||
{
|
{
|
||||||
$this->addElement(
|
if (false === $this->uidDisabled && $this->getElement($this->uidElementName) === null) {
|
||||||
'hidden',
|
$this->addElement(
|
||||||
$this->uidElementName,
|
'hidden',
|
||||||
array(
|
$this->uidElementName,
|
||||||
'ignore' => true,
|
array(
|
||||||
'value' => $this->getName()
|
'ignore' => true,
|
||||||
)
|
'value' => $this->getName()
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user