Skip to content

Commit

Permalink
proper items formating
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoody- committed Jun 28, 2018
1 parent 601b32e commit 750555a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/Components/AjaxSelect/Traits/AjaxServiceControlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,20 @@ protected function processValues($values) {
}

if (count($invalidValues) > 0) {
$validValues = array_merge($validValues, $this->handleInvalidValues($invalidValues) ?: [ ]);
$invalidValues = $this->handleInvalidValues($invalidValues) ?: [ ];

$validValues = array_merge($validValues, $invalidValues);
}

// combine list of ids to identity array i.e. key = value
$items = array_combine($validValues, $validValues);
$validItems = $this->getAjaxEntity()->formatValues($validValues);
if (is_iterable($validItems)) {

This comment has been minimized.

Copy link
@michallohnisky

michallohnisky Jun 28, 2018

Contributor

@vvoody-

Toto dejme pryč, protože podle

formatValues vracet pouze array. Navíc pole je iterable, ale nemůže jít jako parametr do iterator_to_array, takže by to spadlo.

$validItems = iterator_to_array($validItems);
}

// add to list of valid values
$this->setItems($this->getItems() + $items);
$this->setItems($this->getItems() + $validItems);

return $validValues;
}

public function setDefaultValue($value)
{
if (!$this->getForm()->isSubmitted()) {
$items = iterator_to_array($this->getAjaxEntity()->formatValues((array) $value));
$this->setItems($items);
}
parent::setDefaultValue($value);
}
}

0 comments on commit 750555a

Please sign in to comment.