Zend\Form - Quick start

12 important questions on Zend\Form - Quick start

What are the 3 steps to validate forms?

1. Attach an input filter
2. Inject the form data
3. Validate the form (and retrieve messages if any)

Does Form::getData() return filtered or unfiltered data?

Filtered data

What is the purpose of the Zend\InputFilter\InputFilterProviderInterface

Provide a (default) input filter configuration (for a fieldset for example)
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

When will a form return an object on getData() call?

When an object is bound to the form

How can you force a form to return an array on getData() call?

Use FormInterface::VALUES_AS_ARRAY

What is the interface all hydrators have implemented?

Zend\Stdlib\Hydrator\HydratorInterface

Which form view helper shortens your form view code?

formRow view helper

Which method defines the validated fields of a form?

setValidationGroup()

What constant as parameter of setValidationGroup sets validation on all input fields?

FormInterface::VALIDATE_ALL

What are the 15 available form annotations in ZF2?

1. AllowEmpty
2. Attributes
3. ComposedObject
4. ErrorMessage
5. Exclude
6. Filter
7. Flags
8. Hydrator
9. InputFilter
10. Input
11. Name
12. Options
13. Required
14. Type
15. Validator

Are Zend\Form elements by default required?

Yes

What method of AnnotationBuilder builds the form?

AnnotationBuilder::createForm($className)

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo