From 16cdd76c9e599c906792fdbb9cc48dcf9315e166 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 30 Sep 2015 15:37:15 +0200 Subject: [PATCH] NavigationItemForm: Strip the current base url from an item's url --- .../forms/Navigation/NavigationItemForm.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/application/forms/Navigation/NavigationItemForm.php b/application/forms/Navigation/NavigationItemForm.php index 0011b044c..cd6eca70d 100644 --- a/application/forms/Navigation/NavigationItemForm.php +++ b/application/forms/Navigation/NavigationItemForm.php @@ -4,6 +4,7 @@ namespace Icinga\Forms\Navigation; use Icinga\Web\Form; +use Icinga\Web\Url; class NavigationItemForm extends Form { @@ -71,4 +72,20 @@ class NavigationItemForm extends Form ) ); } + + /** + * {@inheritdoc} + */ + public function getValues($suppressArrayNotation = false) + { + $values = parent::getValues($suppressArrayNotation); + if (isset($values['url']) && $values['url']) { + $url = Url::fromPath($values['url']); + if (! $url->isExternal() && ($relativePath = $url->getRelativeUrl())) { + $values['url'] = $relativePath; + } + } + + return $values; + } }