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()
What are available twig functions for working with forms?
form() form_start() form_end() form_label() form_help() form_errors() form_widget() form_row() form_rest() form_parent() csrf_token()
What configuration key defines possible form themes?
twig.form_themes
What twig tag is used to define a local form theme?
form_theme
What does the form_theme form _self
tag do?
Enables to override form parts in the same template
What does inherit_data option do?
Tells form type to access the data from the form that is the user of this form type.
What methods does Symfony\Component\Form\FormTypeGuesserInterface define?
guessType()
guessRequired()
guessMaxLength()
guessPattern()
What confidence constants are defined in Symfony\Component\Form\Guess\Guess class?
VERY_HIGH_CONFIDENCE
HIGH_CONFIDENCE
MEDIUM_CONFIDENCE
LOW_CONFIDENCE
What type of object is returned by the guessType() method?
Symfony\Component\Form\Guess\TypeGuess
What type of object is returned by the guessRequired(), guessMaxLength() and guessPattern() methods?
Symfony\Component\Form\Guess\ValueGuess
What are the three core object types of Symfony Form component?
Symfony\Component\Form\FormTypeInterface
Symfony\Component\Form\Form
Symfony\Component\Form\FormView
What does FormInterface isSynchronized() method returning false mean?
That form data transformers resulted in an exception.
What are available twig filters for working with forms?
humanize
form_encode_currency
What are available twig tests for working with forms?
selectedchoice
rootform