Auto-focus submit button in the confirm removal form

This commit is contained in:
Eric Lippmann 2016-01-25 07:06:39 +01:00
parent 8a17cc5161
commit 0e4b9f1672
1 changed files with 16 additions and 1 deletions

View File

@ -11,11 +11,26 @@ use Icinga\Web\Form;
class ConfirmRemovalForm extends Form
{
/**
* Initialize this form
* {@inheritdoc}
*/
public function init()
{
$this->setName('form_confirm_removal');
$this->getSubmitLabel() ?: $this->setSubmitLabel($this->translate('Confirm Removal'));
}
/**
* {@inheritdoc}
*/
public function addSubmitButton()
{
parent::addSubmitButton();
if (($submit = $this->getElement('btn_submit')) !== null) {
$class = $submit->getAttrib('class');
$submit->setAttrib('class', empty($class) ? 'autofocus' : $class . ' autofocus');
}
return $this;
}
}