Remove properties from ConfirmRemovalForm and update it

Which object should be removed needs not to be a part of a form but is
accessible from the url's query string which should be in the action of the
form.

refs #5525
This commit is contained in:
Johannes Meyer 2014-07-24 16:20:01 +02:00
parent c3731fa79e
commit 26a78dc387

View File

@ -12,57 +12,23 @@ use Icinga\Web\Form;
class ConfirmRemovalForm extends Form class ConfirmRemovalForm extends Form
{ {
/** /**
* The value of the target to remove * Initalize this form
*
* @var string
*/ */
private $removeTarget; public function init()
/**
* The name of the target parameter to remove
*
* @var string
*/
private $targetName;
/**
* Set the remove target in this field to be a hidden field with $name and value $target
*
* @param string $name The name to be set in the hidden field
* @param string $target The value to be set in the hidden field
*/
public function setRemoveTarget($name, $target)
{
$this->targetName = $name;
$this->removeTarget = $target;
}
/**
* Create the confirmation form
*
* @see Form::create()
*/
public function create()
{ {
$this->setName('form_confirm_removal'); $this->setName('form_confirm_removal');
$this->addElement( }
'hidden',
$this->targetName,
array(
'value' => $this->removeTarget,
'required' => true
)
);
/**
* @see Form::addSubmitButton()
*/
public function addSubmitButton()
{
$this->addElement( $this->addElement(
'button', 'submit',
'btn_submit', 'btn_submit',
array( array(
'type' => 'submit', 'label' => t('Confirm Removal')
'escape' => false,
'value' => '1',
'class' => 'btn btn-cta btn-common',
'label' => '<i class="icinga-icon-remove"></i> Confirm Removal'
) )
); );
} }