Form Flashcards

1
Q

What options does BaseType provide?

A
block_name
block_prefix
disabled
label
label_format
row_attr
label_translation_parameters
attr_translation_parameters
attr
translation_domain
auto_initialize
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the available variables in label_format property?

A

%id%

%name%

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are available field options for ChoiceType?

A
choices
choice_attr
choice_filter
choice_label
choice_loader
choice_name
choice_translation_domain
choice_value
expanded
group_by
multiple
placeholder
preferred_choices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

By what type is the uploaded file represented?

A

Symfony\Component\HttpFoundation\File\UploadedFile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What methods does Symfony\Component\Form\FormBuilderInterface define?

A

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();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What methods does Symfony\Component\Form\FormFactoryInterface define?

A

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 = []);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What methods does Symfony\Component\Form\FormTypeInterface define?

A

buildForm(FormBuilderInterface $builder, array $options);
buildView(FormView $view, FormInterface $form, array $options);
finishView(FormView $view, FormInterface $form, array $options);
configureOptions(OptionsResolver $resolver);
getBlockPrefix();
getParent();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is note worthy about the following case: a form type has the inherit_data option set to true?

A

Data transformers are not applied to such fields.

Data mappers are not used as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What methods does Symfony\Component\Form\DataTransformerInterface define?

A

transform($value);

reverseTransform($value);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the three forms of form data?

A

Model data
Normalized data
View data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What methods does Symfony\Component\Form\FormTypeExtensionInterface define?

A

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;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What methods does Symfony\Component\Form\DataMapperInterface define?

A

mapDataToForms($viewData, iterable $forms);

mapFormsToData(iterable $forms, &$viewData);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is special about setting second parameter of Symfony\Component\Form\FormInterface to false?

A

Missing fields are not validated via forms validation routine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens if you set validation_groups form type option to false?

A

Validations are disabled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is the validator component connected to the form component?

A

Via FormTypeValidatorExtension, RepeatedTypeValidatorExtension, SubmitTypeValidatorExtension, UploadValidatorExtension.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What events does Symfony\Component\Form\FormEvents define?

A
FormEvents::PRE_SUBMIT
FormEvents::SUBMIT
FormEvents::POST_SUBMIT
FormEvents::PRE_SET_DATA
FormEvents::POST_SET_DATA
17
Q

How is the FormEvents::PRE_SET_DATA loop detected and prevented?

A

By locking the Form::setData() method and requiring to use FormEvent::setData().

18
Q

How is the security-csrf component connected with the form component?

A

Via the Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener which is listening to the FormEvents::PRE_SUBMIT event.

19
Q

What data is passed with the FormEvents::PRE_SET_DATA event?

A

Model data

20
Q

What data is passed with the FormEvents::POST_SET_DATA event?

A

Model data

21
Q

What data is passed with the FormEvents::PRE_SUBMIT event?

A

Request data

22
Q

What data is passed with the FormEvents::SUBMIT event?

A

Normalized data

23
Q

What data is passed with the FormEvents::POST_SUBMIT event?

A

View data

24
Q

What are child parts of form_row() structure?

A

form_label()
form_errors()
form_help()
form_widget()

25
Q

What are available twig functions for working with forms?

A
form()
form_start()
form_end()
form_label()
form_help()
form_errors()
form_widget()
form_row()
form_rest()
form_parent()
csrf_token()
26
Q

What configuration key defines possible form themes?

A

twig.form_themes

27
Q

What twig tag is used to define a local form theme?

A

form_theme

28
Q

What does the form_theme form _self tag do?

A

Enables to override form parts in the same template

29
Q

What does inherit_data option do?

A

Tells form type to access the data from the form that is the user of this form type.

30
Q

What methods does Symfony\Component\Form\FormTypeGuesserInterface define?

A

guessType()
guessRequired()
guessMaxLength()
guessPattern()

31
Q

What confidence constants are defined in Symfony\Component\Form\Guess\Guess class?

A

VERY_HIGH_CONFIDENCE
HIGH_CONFIDENCE
MEDIUM_CONFIDENCE
LOW_CONFIDENCE

32
Q

What type of object is returned by the guessType() method?

A

Symfony\Component\Form\Guess\TypeGuess

33
Q

What type of object is returned by the guessRequired(), guessMaxLength() and guessPattern() methods?

A

Symfony\Component\Form\Guess\ValueGuess

34
Q

What are the three core object types of Symfony Form component?

A

Symfony\Component\Form\FormTypeInterface
Symfony\Component\Form\Form
Symfony\Component\Form\FormView

35
Q

What does FormInterface isSynchronized() method returning false mean?

A

That form data transformers resulted in an exception.

36
Q

What are available twig filters for working with forms?

A

humanize

form_encode_currency

37
Q

What are available twig tests for working with forms?

A

selectedchoice

rootform