NavigationController: Pass through the default url without creating the form

This commit is contained in:
Johannes Meyer 2015-10-01 13:55:12 +02:00
parent aa3bff532e
commit b80cfe7cdc
2 changed files with 13 additions and 1 deletions

View File

@ -206,7 +206,7 @@ class NavigationController extends Controller
$form->addDescription($this->translate('Create a new navigation item, such as a menu entry or dashlet.')); $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 // 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) { $form->setOnSuccess(function (NavigationConfigForm $form) {
$data = array_filter($form->getValues()); $data = array_filter($form->getValues());

View File

@ -74,6 +74,8 @@ class NavigationConfigForm extends ConfigForm
*/ */
protected $itemTypes; protected $itemTypes;
private $defaultUrl;
/** /**
* Initialize this form * Initialize this form
*/ */
@ -680,6 +682,14 @@ class NavigationConfigForm extends ConfigForm
$itemForm->create($formData); // May require a parent which gets set by addSubForm() $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 * Populate the configuration of the navigation item to load
*/ */
@ -689,6 +699,8 @@ class NavigationConfigForm extends ConfigForm
$data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray(); $data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray();
$data['name'] = $this->itemToLoad; $data['name'] = $this->itemToLoad;
$this->populate($data); $this->populate($data);
} elseif ($this->defaultUrl !== null) {
$this->populate(array('url' => $this->defaultUrl));
} }
} }