Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList
A choice list for choices of arbitrary data types.
Choices and labels are passed in two arrays. The indices of the choices
and the labels should match. Choices may also be given as hierarchy of
unlimited depth by creating nested arrays. The title of the sub-hierarchy
can be stored in the array key pointing to the nested array. The topmost
level of the hierarchy may also be a \Traversable.
<code>
$choices = array(true, false);
$labels = array('Agree', 'Disagree');
$choiceList = new ChoiceList($choices, $labels);
</code>
- Author: Bernhard Schussek <bschussek@gmail.com>
Synopsis
class ChoiceList
implements
ChoiceListInterface
{
- // members
- private array $choices;
- private array $values;
- private array $preferredViews;
- private array $remainingViews;
- // methods
- public void __construct()
- protected void initialize()
- public void getChoices()
- public void getValues()
- public void getPreferredViews()
- public void getRemainingViews()
- public void getChoicesForValues()
- public void getValuesForChoices()
- public void getIndicesForChoices()
- public void getIndicesForValues()
- protected void addChoices()
- protected void addChoiceGroup()
- protected void addChoice()
- protected Boolean isPreferred()
- protected integer|string createIndex()
- protected string createValue()
- protected string fixValue()
- protected array fixValues()
- protected integer|string fixIndex()
- protected array fixIndices()
- protected mixed fixChoice()
- protected array fixChoices()
Hierarchy
Extended by
- Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList
- Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList
- Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList
- Symfony\Bridge\Propel1\Form\ChoiceList\ModelChoiceList
Implements
Members
private
- $choices
—
array
The choices with their indices as keys. - $preferredViews
—
array
The preferred view objects as hierarchy containing also the choice groups with the indices of the matching choices as bottom-level keys. - $remainingViews
—
array
The non-preferred view objects as hierarchy containing also the choice groups with the indices of the matching choices as bottom-level keys. - $values
—
array
The choice values with the indices of the matching choices as keys.
Methods
protected
- addChoice() — Adds a new choice.
- addChoiceGroup() — Recursively adds a choice group.
- addChoices() — Recursively adds the given choices to the list.
- createIndex() — Creates a new unique index for this choice.
- createValue() — Creates a new unique value for this choice.
- fixChoice() — Fixes the data type of the given choice to avoid comparison problems.
- fixChoices() — Fixes the data type of the given choices to avoid comparison problems.
- fixIndex() — Fixes the data type of the given choice index to avoid comparison problems.
- fixIndices() — Fixes the data types of the given choice indices to avoid comparison problems.
- fixValue() — Fixes the data type of the given choice value to avoid comparison problems.
- fixValues() — Fixes the data types of the given choice values to avoid comparison problems.
- initialize() — Initializes the list with choices.
- isPreferred() — Returns whether the given choice should be preferred judging by the given array of preferred choices.
public
- __construct() — Creates a new choice list.
- getChoices() — {@inheritdoc}
- getChoicesForValues() — {@inheritdoc}
- getIndicesForChoices() — {@inheritdoc}
- getIndicesForValues() — {@inheritdoc}
- getPreferredViews() — {@inheritdoc}
- getRemainingViews() — {@inheritdoc}
- getValues() — {@inheritdoc}
- getValuesForChoices() — {@inheritdoc}