From 200982e4f5ccb2a98312cdce22b94f7ccace631e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 13 Mar 2015 03:59:43 +0100 Subject: [PATCH] Set form action automatically only if Form::setAction() has not been called refs #8605 --- library/Icinga/Web/Form.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 3ff9950283..faa2124585 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -535,7 +535,13 @@ public function create(array $formData = array()) ->addCsrfCounterMeasure() ->addSubmitButton(); - if ($this->getAction() === '') { + if ($this->getAttrib('action') === null) { + // Use Form::getAttrib() instead of Form::getAction() here because we want to explicitly check against + // null. Form::getAction() would return the empty string '' if the action is not set. + // For not setting the action attribute use Form::setAction(''). This is required for for the + // accessibility's enable/disable auto-refresh mechanic + + // TODO(el): Re-evalute this necessity. JavaScript could use the container's URL if there's no action set. // We MUST set an action as JS gets confused otherwise, if // this form is being displayed in an additional column $this->setAction(Url::fromRequest()->without(array_keys($this->getElements())));