Skip to content

Commit

Permalink
NavigationController: Pass through the default url without creating t…
Browse files Browse the repository at this point in the history
…he form
  • Loading branch information
Johannes Meyer committed Oct 1, 2015
1 parent aa3bff5 commit b80cfe7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/controllers/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function addAction()
$form->addDescription($this->translate('Create a new navigation item, such as a menu entry or dashlet.'));

// TODO: Fetch all "safe" parameters from the url and populate them
$form->populate(array('url' => rawurldecode($this->params->get('url', ''))));
$form->setDefaultUrl(rawurldecode($this->params->get('url', '')));

$form->setOnSuccess(function (NavigationConfigForm $form) {
$data = array_filter($form->getValues());
Expand Down
12 changes: 12 additions & 0 deletions application/forms/Navigation/NavigationConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class NavigationConfigForm extends ConfigForm
*/
protected $itemTypes;

private $defaultUrl;

/**
* Initialize this form
*/
Expand Down Expand Up @@ -680,6 +682,14 @@ public function createElements(array $formData)
$itemForm->create($formData); // May require a parent which gets set by addSubForm()
}

/**
* DO NOT USE! This will be removed soon, very soon...
*/
public function setDefaultUrl($url)
{
$this->defaultUrl = $url;
}

/**
* Populate the configuration of the navigation item to load
*/
Expand All @@ -689,6 +699,8 @@ public function onRequest()
$data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray();
$data['name'] = $this->itemToLoad;
$this->populate($data);
} elseif ($this->defaultUrl !== null) {
$this->populate(array('url' => $this->defaultUrl));
}
}

Expand Down

0 comments on commit b80cfe7

Please sign in to comment.