Skip to content

Commit

Permalink
DashletForm: Make sure that we won't try to save invalid section names
Browse files Browse the repository at this point in the history
refs #3648
  • Loading branch information
nilmerg committed Feb 1, 2019
1 parent 0f4a450 commit c3e602f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions application/forms/Dashboard/DashletForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ public function createElements(array $formData)
$panes = $this->dashboard->getPaneKeyTitleArray();
}

$sectionNameValidator = ['Callback', true, [
'callback' => function ($value) {
if (strpos($value, '[') === false && strpos($value, ']') === false) {
return true;
}
},
'messages' => [
'callbackValue' => $this->translate('Brackets ([, ]) cannot be used here')
]
]];

$this->addElement(
'hidden',
'org_pane',
Expand Down Expand Up @@ -80,7 +91,8 @@ public function createElements(array $formData)
array(
'required' => true,
'label' => $this->translate('Dashlet Title'),
'description' => $this->translate('Enter a title for the dashlet.')
'description' => $this->translate('Enter a title for the dashlet.'),
'validators' => [$sectionNameValidator]
)
);
$this->addElement(
Expand Down Expand Up @@ -109,7 +121,8 @@ public function createElements(array $formData)
array(
'required' => true,
'label' => $this->translate('New Dashboard Title'),
'description' => $this->translate('Enter a title for the new dashboard')
'description' => $this->translate('Enter a title for the new dashboard'),
'validators' => [$sectionNameValidator]
)
);
} else {
Expand Down

0 comments on commit c3e602f

Please sign in to comment.