QuickForm: split method, new helpers for buttons

This commit is contained in:
Thomas Gelf 2017-07-14 08:59:44 +02:00
parent 5938f5051a
commit 8f8f9a508e
1 changed files with 28 additions and 5 deletions

View File

@ -95,6 +95,28 @@ abstract class QuickForm extends QuickBaseForm
return $this; return $this;
} }
protected function addSubmitButton($label)
{
$el = $this->createElement('submit', $label)
->setLabel($label)
->setDecorators(array('ViewHelper'));
$this->submitButtonName = $el->getName();
$this->setSubmitLabel($label);
$this->addElement($el);
}
protected function addStandaloneSubmitButton($label)
{
$this->addSubmitButton($label);
$this->addDisplayGroup([$this->submitButtonName], 'buttons', array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'p')),
),
'order' => 1000,
));
}
protected function addSubmitButtonIfSet() protected function addSubmitButtonIfSet()
{ {
if (false === ($label = $this->getSubmitLabel())) { if (false === ($label = $this->getSubmitLabel())) {
@ -105,11 +127,7 @@ abstract class QuickForm extends QuickBaseForm
return; return;
} }
$el = $this->createElement('submit', $label) $this->addSubmitButton($label);
->setLabel($label)
->setDecorators(array('ViewHelper'));
$this->submitButtonName = $el->getName();
$this->addElement($el);
$fakeEl = $this->createElement('submit', '_FAKE_SUBMIT', array( $fakeEl = $this->createElement('submit', '_FAKE_SUBMIT', array(
'role' => 'none', 'role' => 'none',
@ -129,6 +147,11 @@ abstract class QuickForm extends QuickBaseForm
) )
); );
$this->addButtonDisplayGroup();
}
protected function addButtonDisplayGroup()
{
$grp = array( $grp = array(
$this->submitButtonName, $this->submitButtonName,
$this->deleteButtonName $this->deleteButtonName