Form Flashcards
What options does BaseType provide?
block_name block_prefix disabled label label_format row_attr label_translation_parameters attr_translation_parameters attr translation_domain auto_initialize
What are the available variables in label_format property?
%id%
%name%
What are available field options for ChoiceType?
choices choice_attr choice_filter choice_label choice_loader choice_name choice_translation_domain choice_value expanded group_by multiple placeholder preferred_choices
By what type is the uploaded file represented?
Symfony\Component\HttpFoundation\File\UploadedFile
What methods does Symfony\Component\Form\FormBuilderInterface define?
add($child, string $type = null, array $options = []);
create(string $name, string $type = null, array $options = []);
get(string $name);
remove(string $name);
has(string $name);
all();
getForm();
What methods does Symfony\Component\Form\FormFactoryInterface define?
create(string $type = ‘Symfony\Component\Form\Extension\Core\Type\FormType’, $data = null, array $options = []);
createNamed(string $name, string $type = ‘Symfony\Component\Form\Extension\Core\Type\FormType’, $data = null, array $options = []);
createForProperty(string $class, string $property, $data = null, array $options = []);
createBuilder(string $type = ‘Symfony\Component\Form\Extension\Core\Type\FormType’, $data = null, array $options = []);
createNamedBuilder(string $name, string $type = ‘Symfony\Component\Form\Extension\Core\Type\FormType’, $data = null, array $options = []);
createBuilderForProperty(string $class, string $property, $data = null, array $options = []);
What methods does Symfony\Component\Form\FormTypeInterface define?
buildForm(FormBuilderInterface $builder, array $options);
buildView(FormView $view, FormInterface $form, array $options);
finishView(FormView $view, FormInterface $form, array $options);
configureOptions(OptionsResolver $resolver);
getBlockPrefix();
getParent();
What is note worthy about the following case: a form type has the inherit_data option set to true?
Data transformers are not applied to such fields.
Data mappers are not used as well.
What methods does Symfony\Component\Form\DataTransformerInterface define?
transform($value);
reverseTransform($value);
What are the three forms of form data?
Model data
Normalized data
View data
What methods does Symfony\Component\Form\FormTypeExtensionInterface define?
buildForm(FormBuilderInterface $builder, array $options);
buildView(FormView $view, FormInterface $form, array $options);
finishView(FormView $view, FormInterface $form, array $options);
configureOptions(OptionsResolver $resolver);
public static function getExtendedTypes(): iterable;
What methods does Symfony\Component\Form\DataMapperInterface define?
mapDataToForms($viewData, iterable $forms);
mapFormsToData(iterable $forms, &$viewData);
What is special about setting second parameter of Symfony\Component\Form\FormInterface to false?
Missing fields are not validated via forms validation routine.
What happens if you set validation_groups form type option to false?
Validations are disabled.
How is the validator component connected to the form component?
Via FormTypeValidatorExtension, RepeatedTypeValidatorExtension, SubmitTypeValidatorExtension, UploadValidatorExtension.
What events does Symfony\Component\Form\FormEvents define?
FormEvents::PRE_SUBMIT FormEvents::SUBMIT FormEvents::POST_SUBMIT FormEvents::PRE_SET_DATA FormEvents::POST_SET_DATA
How is the FormEvents::PRE_SET_DATA loop detected and prevented?
By locking the Form::setData() method and requiring to use FormEvent::setData().
How is the security-csrf component connected with the form component?
Via the Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener which is listening to the FormEvents::PRE_SUBMIT event.
What data is passed with the FormEvents::PRE_SET_DATA event?
Model data
What data is passed with the FormEvents::POST_SET_DATA event?
Model data
What data is passed with the FormEvents::PRE_SUBMIT event?
Request data
What data is passed with the FormEvents::SUBMIT event?
Normalized data
What data is passed with the FormEvents::POST_SUBMIT event?
View data
What are child parts of form_row() structure?
form_label()
form_errors()
form_help()
form_widget()