Symfony2 API
Class

Symfony\Bridge\Propel1\Form\ChoiceList\ModelChoiceList

class ModelChoiceList extends ObjectChoiceList

Widely inspired by the EntityChoiceList.

Methods

__construct(string $class, string $labelPath = null, array $choices = null, ModelCriteria $queryObject = null, string $groupPath = null, array|ModelCriteria $preferred = array(), PropertyAccessorInterface $propertyAccessor = null)

Creates a new choice list.

string getClass()

Returns the class name

array getChoices()

Returns the list of model objects

array getValues()

Returns the values for the model objects

array getPreferredViews()

Returns the choice views of the preferred choices as nested array with the choice groups as top-level keys.

array getRemainingViews()

Returns the choice views of the choices that are not preferred as nested array with the choice groups as top-level keys.

array getChoicesForValues(array $values)

Returns the model objects corresponding to the given values.

array getValuesForChoices(array $models)

Returns the values corresponding to the given model objects.

array getIndicesForChoices(array $models)

Returns the indices corresponding to the given models.

array getIndicesForValues(array $values)

Returns the models corresponding to the given values.

Details

at line 82
public __construct(string $class, string $labelPath = null, array $choices = null, ModelCriteria $queryObject = null, string $groupPath = null, array|ModelCriteria $preferred = array(), PropertyAccessorInterface $propertyAccessor = null)

Creates a new choice list.

Parameters

string $class The FQCN of the model class to be loaded.
string $labelPath A property path pointing to the property used for the choice labels.
array $choices An optional array to use, rather than fetching the models.
ModelCriteria $queryObject The query to use retrieving model data from database.
string $groupPath A property path pointing to the property used to group the choices.
array|ModelCriteria $preferred The preferred items of this choice. Either an array if $choices is given, or a ModelCriteria to be merged with the $queryObject.
PropertyAccessorInterface $propertyAccessor The reflection graph for reading property paths.

Exceptions

UnexpectedTypeException If the choices are not an array or \Traversable.

See also

Symfony\Bridge\Propel1\Form\Type\ModelType How to use the preferred choices.

at line 116
public string getClass()

Returns the class name

Return Value

string

at line 128
public array getChoices()

Returns the list of model objects

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 144
public array getValues()

Returns the values for the model objects

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 161
public array getPreferredViews()

Returns the choice views of the preferred choices as nested array with the choice groups as top-level keys.

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 178
public array getRemainingViews()

Returns the choice views of the choices that are not preferred as nested array with the choice groups as top-level keys.

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 196
public array getChoicesForValues(array $values)

Returns the model objects corresponding to the given values.

Parameters

array $values

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 222
public array getValuesForChoices(array $models)

Returns the values corresponding to the given model objects.

Parameters

array $models

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 256
public array getIndicesForChoices(array $models)

Returns the indices corresponding to the given models.

Parameters

array $models

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

at line 291
public array getIndicesForValues(array $values)

Returns the models corresponding to the given values.

Parameters

array $values

Return Value

array

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface