From 8f8f9a508ea27d69938f94995402d824c4fd2322 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 14 Jul 2017 08:59:44 +0200 Subject: [PATCH] QuickForm: split method, new helpers for buttons --- library/Director/Web/Form/QuickForm.php | 33 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/library/Director/Web/Form/QuickForm.php b/library/Director/Web/Form/QuickForm.php index cf525d39..3e09e3a1 100644 --- a/library/Director/Web/Form/QuickForm.php +++ b/library/Director/Web/Form/QuickForm.php @@ -95,6 +95,28 @@ abstract class QuickForm extends QuickBaseForm 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() { if (false === ($label = $this->getSubmitLabel())) { @@ -105,11 +127,7 @@ abstract class QuickForm extends QuickBaseForm return; } - $el = $this->createElement('submit', $label) - ->setLabel($label) - ->setDecorators(array('ViewHelper')); - $this->submitButtonName = $el->getName(); - $this->addElement($el); + $this->addSubmitButton($label); $fakeEl = $this->createElement('submit', '_FAKE_SUBMIT', array( 'role' => 'none', @@ -129,6 +147,11 @@ abstract class QuickForm extends QuickBaseForm ) ); + $this->addButtonDisplayGroup(); + } + + protected function addButtonDisplayGroup() + { $grp = array( $this->submitButtonName, $this->deleteButtonName