Skip to content

Commit

Permalink
update database select formfield class
Browse files Browse the repository at this point in the history
  • Loading branch information
pressi committed Feb 22, 2018
1 parent 92c818b commit 25118d3
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions FormField/DatabaseSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function getOptions()
{
$arrOptions[] = array
(
'value' => $this->optionsBlankLabel,
'value' => '',
'label' => $this->optionsBlankLabel,
'type' => 'option',
'selected' => false
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 25118d3

Please sign in to comment.