Skip to content

Commit

Permalink
Set form action automatically only if Form::setAction() has not been …
Browse files Browse the repository at this point in the history
…called

refs #8605
  • Loading branch information
lippserd committed Mar 13, 2015
1 parent b5abff0 commit 200982e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/Icinga/Web/Form.php
Expand Up @@ -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())));
Expand Down

0 comments on commit 200982e

Please sign in to comment.