/** * Returns whether the given choice is selected. * * @param mixed $choice The choice * * @return Boolean Whether the choice is selected */ public static function isChoiceSelected($choice, $value) { $choice = FormUtil::toArrayKey($choice); // The value should already have been converted by value transformers, // otherwise we had to do the conversion on every call of this method if (is_array($value)) { return false !== array_search($choice, $value, true); } return $choice === $value; }