Skip to content

Latest commit

History

History
44 lines (33 loc) 路 1.67 KB

building_the_form.md

File metadata and controls

44 lines (33 loc) 路 1.67 KB

Building the form

When build BasketballPositionType as form field, you don't need to specify some additional parameters. Just add property to the form builder and EnumTypeGuesser will do all work for you. That's how:

$builder->add('position');

If you need to add some extra parameters, just skip the second field type parameter:

$builder->add('position', null, [
    'required' => true,
    'attr' => [
        'class' => 'some-class',
    ],
]);

If for some reason you need to specify full config, it can look like this:

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

$builder->add('position', ChoiceType::class, [
    'choices' => BasketballPositionType::getChoices(),
]);

EnumTypeGuesser process only DBAL types that are children of AbstractEnumType. All other custom DBAL types, which are defined, will be skipped from guessing.


More features