protected function createDefaultButton() {
parent::createDefaultButton();
- $this->getButtons()['submitButton']->attribute('data-type', 'submit');
+ $this->getButton('submitButton')->attribute('data-type', 'submit');
if ($this->isCancelable()) {
$this->addButton(
return $this->action;
}
+ /**
+ * @inheritDoc
+ */
+ public function getButton($buttonId) {
+ if (!$this->hasButton($buttonId)) {
+ throw new \InvalidArgumentException("Unknown button with id '{$buttonId}'.");
+ }
+
+ return $this->buttons[$buttonId];
+ }
+
/**
* @inheritDoc
*/
public function getButtons() {
return $this->buttons;
}
-
+
/**
* @inheritDoc
*/
return $this->successMessage;
}
+ /**
+ * @inheritDoc
+ */
+ public function hasButton($buttonId) {
+ return isset($this->buttons[$buttonId]);
+ }
+
/**
* @inheritDoc
*/
*/
public function getAction();
+ /**
+ * Returns the button with the given id.
+ *
+ * @param string $buttonId id of requested button
+ * @return IFormButton
+ *
+ * @throws \InvalidArgumentException if no such button exists
+ */
+ public function getButton($buttonId);
+
/**
* Returns the buttons registered for this form document.
*
*/
public function getSuccessMessage();
+ /**
+ * Returns `true` if a button with the given id exists and `false` otherwise.
+ *
+ * @param string $buttonId id of checked button
+ * @return boolean
+ */
+ public function hasButton($buttonId);
+
/**
* Returns `true` if the default button is added to the form during in the `build()` method
* and `false` otherwise.