protected function getSelectedChoices(array $values, $value = null)
    {
        $structuredValues = $this->loadChoiceList($value)->getStructuredValues();
        $values = $this->forceStringValues($values);
        $allChoices = [];
        $choices = [];
        $isGrouped = false;

        foreach ($structuredValues as $group => $choice) {
            // group
            if (\is_array($choice)) {
                $isGrouped = true;
                foreach ($choice as $choiceKey => $choiceValue) {
                    if ($this->allChoices || \in_array($choiceValue, $values)) {
                        $choices[$group][$choiceKey] = $choiceValue;
                        $allChoices[$choiceKey] = $choiceValue;
                    }
                }
            } elseif ($this->allChoices || \in_array($choice, $values)) {
                $choices[$group] = $choice;
                $allChoices[$group] = $choice;
            }
        }

        if ($this->isAllowAdd()) {
            $choices = $this->addNewTagsInChoices($choices, $allChoices, $values, $isGrouped);
        }

        return (array) $choices;
    }
protected function getSelectedChoices(array $values, $value = null)
    {
        $structuredValues = $this->loadChoiceList($value)->getStructuredValues();
        $values = $this->forceStringValues($values);
        $allChoices = [];
        $choices = [];
        $isGrouped = false;

        foreach ($structuredValues as $group => $choice) {
            // group
            if (\is_array($choice)) {
                $isGrouped = true;
                foreach ($choice as $choiceKey => $choiceValue) {
                    if ($this->allChoices || \in_array($choiceValue, $values)) {
                        $choices[$group][$choiceKey] = $choiceValue;
                        $allChoices[$choiceKey] = $choiceValue;
                    }
                }
            } elseif ($this->allChoices || \in_array($choice, $values)) {
                $choices[$group] = $choice;
                $allChoices[$group] = $choice;
            }
        }

        if ($this->isAllowAdd()) {
            $choices = $this->addNewTagsInChoices($choices, $allChoices, $values, $isGrouped);
        }

        return (array) $choices;
    }
protected function getSelectedChoices ( array $ values , $ value = null ) { $ structuredValues = $ this -> loadChoiceList ( $ value ) -> getStructuredValues ( ) ; $ values = $ this -> forceStringValues ( $ values ) ; $ allChoices = [ ] ; $ choices = [ ] ; $ isGrouped = false ; foreach ( $ structuredValues as $ group => $ choice ) { // group if ( \ is_array ( $ choice ) ) { $ isGrouped = true ; foreach ( $ choice as $ choiceKey => $ choiceValue ) { if ( $ this -> allChoices || \ in_array ( $ choiceValue , $ values ) ) { $ choices [ $ group ] [ $ choiceKey ] = $ choiceValue ; $ allChoices [ $ choiceKey ] = $ choiceValue ; } } } elseif ( $ this -> allChoices || \ in_array ( $ choice , $ values ) ) { $ choices [ $ group ] = $ choice ; $ allChoices [ $ group ] = $ choice ; } } if ( $ this -> isAllowAdd ( ) ) { $ choices = $ this -> addNewTagsInChoices ( $ choices , $ allChoices , $ values , $ isGrouped ) ; } return ( array ) $ choices ; }
Keep only the selected values in choices.

@param array         $values The selected values
@param null|callable $value  The callable function

@return array The selected choices
Keep only the selected values in choices .