From 25118d334a7978243e746a6dcd04c879f2f506e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Pre=C3=9Fl?= Date: Thu, 22 Feb 2018 01:06:51 +0100 Subject: [PATCH] update database select formfield class --- FormField/DatabaseSelect.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/FormField/DatabaseSelect.php b/FormField/DatabaseSelect.php index 46d107d..3bf1f57 100644 --- a/FormField/DatabaseSelect.php +++ b/FormField/DatabaseSelect.php @@ -35,7 +35,7 @@ protected function getOptions() { $arrOptions[] = array ( - 'value' => $this->optionsBlankLabel, + 'value' => '', 'label' => $this->optionsBlankLabel, 'type' => 'option', 'selected' => false @@ -75,6 +75,22 @@ protected function getOptions() + /** + * Check whether an input is one of the given options + * + * @param mixed $varInput The input string or array + * + * @return boolean True if the selected option exists + */ + protected function isValidOption($varInput) + { + $this->arrOptions = $this->getOptions(); + + return parent::isValidOption( $varInput ); + } + + + /** * Generate the widget and return it as string * @@ -186,16 +202,17 @@ protected function getEventOptions($arrOptions = array() ) $eventKey = $strDate . ' ' . $strTitle; - if( preg_match('/load-on-post/', $this->class) ) + $eventIdOrAlias = \Input::get("event"); //(\Config::get("useAutoItem") ? \Input::get("auto_item") : (\Input::get("events")?:\Input::get("event"))); + + if( preg_match('/load-on-post/', $this->class) && $eventIdOrAlias ) { - $eventIdOrAlias = \Input::get("event"); //(\Config::get("useAutoItem") ? \Input::get("auto_item") : (\Input::get("events")?:\Input::get("event"))); $objEvent = \CalendarEventsModel::findByIdOrAlias( $eventIdOrAlias ); if( $objEvent && $objEvent->id === $arrEvent['id'] ) { $arrOptions[] = array ( - 'value' => $eventKey . ' (' . $arrEvent['id'] . ')', + 'value' => \StringUtil::decodeEntities($eventKey) . ' (' . $arrEvent['id'] . ')', 'label' => $eventKey, 'type' => 'option', 'selected' => false @@ -206,7 +223,7 @@ protected function getEventOptions($arrOptions = array() ) { $arrOptions[] = array ( - 'value' => $eventKey . ' (' . $arrEvent['id'] . ')', + 'value' => \StringUtil::decodeEntities($eventKey) . ' (' . $arrEvent['id'] . ')', 'label' => $eventKey, 'type' => 'option', 'selected' => false