diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index bbb940e72..b0fb33c20 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -96,7 +96,11 @@ class DashletForm extends SetupNewDashboardForm $this->clearPopulatedValue('pane'); } - $populatedPane = $this->requestUrl->getParam('pane', $this->getPopulatedValue('pane', reset($panes))); + $populatedPane = $this->getPopulatedValue('pane', $this->requestUrl->getParam('pane')); + if (! $populatedPane || ! in_array($populatedPane, $panes)) { + $populatedPane = reset($panes); + } + $disable = empty($panes) || $populatedHome === self::CREATE_NEW_HOME; $this->addElement('select', 'pane', [ 'class' => 'autosubmit', @@ -250,9 +254,7 @@ class DashletForm extends SetupNewDashboardForm * supposed to when the original home contains a dashboard with the same name * {@see DashboardHome::manageEntry()} for details */ - $selectedPane = $this->getPopulatedValue('pane'); - if ((! $selectedPane || $selectedPane === self::CREATE_NEW_PANE) - && ! $currentHome->hasEntry($currentPane->getName())) { + if (! $currentHome->hasEntry($currentPane->getName()) || $currentHome->getName() === $orgHome->getName()) { $orgHome->setEntries([]); } diff --git a/application/forms/Dashboard/SetupNewDashboardForm.php b/application/forms/Dashboard/SetupNewDashboardForm.php index 3d4c2532e..459db8599 100644 --- a/application/forms/Dashboard/SetupNewDashboardForm.php +++ b/application/forms/Dashboard/SetupNewDashboardForm.php @@ -54,7 +54,7 @@ class SetupNewDashboardForm extends BaseDashboardForm foreach (self::$moduleDashlets as $module => $dashlets) { /** @var Dashlet $dashlet */ foreach ($dashlets as $dashlet) { - $element = str_replace(' ', '_', $module . '|' . $dashlet->getName()); + $element = spl_object_hash($dashlet); if ($this->getPopulatedValue($element) === 'y' || (! $strict && $this->getPopulatedValue($element))) { $title = $this->getPopulatedValue($element); $url = $this->getPopulatedValue($element . '_url'); @@ -123,7 +123,7 @@ class SetupNewDashboardForm extends BaseDashboardForm $multi = new DashletListMultiSelect($dashlet); $multi->setCheckBox($this->createElement( 'checkbox', - $module . '|' . $dashlet->getName(), + spl_object_hash($dashlet), ['class' => 'sr-only'] )); @@ -161,19 +161,24 @@ class SetupNewDashboardForm extends BaseDashboardForm } if (! empty(self::$moduleDashlets)) { - foreach (self::$moduleDashlets as $module => $dashlets) { + foreach (self::$moduleDashlets as $_ => $dashlets) { /** @var Dashlet $dashlet */ foreach ($dashlets as $dashlet) { $this->addHtml(HtmlElement::create('h3', null, t($dashlet->getTitle()))); - $this->addElement('text', $module . '|' . $dashlet->getName(), [ + $objHash = spl_object_hash($dashlet); + if ($this->getPopulatedValue('btn_next')) { + $this->clearPopulatedValue($objHash); + } + + $this->addElement('text', $objHash, [ 'required' => true, 'label' => t('Dashlet Title'), 'value' => $dashlet->getTitle(), 'description' => t('Enter a title for the dashlet'), ]); - $this->addElement('textarea', $module . '|' . $dashlet->getName() . '_url', [ + $this->addElement('textarea', $objHash . '_url', [ 'required' => true, 'label' => t('Url'), 'value' => $dashlet->getUrl()->getRelativeUrl(),