Skip to content

Commit

Permalink
Fix an issue where not having a default empty choice (even with an em…
Browse files Browse the repository at this point in the history
…pty label) would cause selectize to select the first option instead of displaying the placeholder
  • Loading branch information
JoelAlphonso committed Jun 10, 2019
1 parent bc34c41 commit 54cd7b2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Charcoal/Admin/Property/Input/SelectizeInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ protected function collectionLoader()
return $this->collectionLoader;
}

/**
* Retrieve the default empty option structure.
*
* @return array
*/
protected function defaultEmptyChoice()
{
return [
'value' => '',
'label' => ''
];
}

/**
* Retrieve the selectable options.
*
Expand All @@ -211,6 +224,11 @@ protected function collectionLoader()
*/
public function choices()
{
if ($this->p()->allowNull() && !$this->p()->multiple()) {
$prepend = $this->parseChoice('', $this->emptyChoice());
yield $prepend;
}

// When deferred, we want to fetch choices for current values only.
if ($this->deferred()) {
$choices = $this->selectizeVal($this->propertyVal());
Expand Down

0 comments on commit 54cd7b2

Please sign in to comment.