I have a file containing a list of US states.
Alabama
Alaska
etc.
In symfony 2.0, I used ChoiceListInterface.php to use it in my form. I just wrote this:
<?php namespace MyBundle\Form; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; class StateChoiceList implements ChoiceListInterface { public function getChoices() { $lines = file('listes/us_states.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
But now in ChoiceListInterface 7 more functions are implemented:
public function getValues(); public function getPreferredViews(); public function getRemainingViews(); public function getValuesForChoices(array $choices); public function getIndicesForChoices(array $choices); public function getIndicesForValues(array $values);
I read the documentation http://api.symfony.com/2.1/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.html , but in my case I find this unclear and I really donβt understand how to implement them.
Can someone help? Thank you very much
source share