PhpStorm 2018.3 Help

Working with Forms

Most web applications contain one or more forms to collect user input. Symfony comes with a Form component and the FormBuilder functions that make creating and maintaining forms and their validation logic easier. The Symfony Plugin provides code completion and navigation for forms.

Code completion for forms

PhpStorm provides code completion for form fields and fields' parameters. In the editor, press Ctrl+Space to invoke code completion and do any of the following:

  • Access the fields that were posted by calling the createForm method of a form type implementing FormTypeInterface.

    ps symfony form field name completion
  • Access the fields to be added or modified by means of the FormBuilder.

    ps symfony form builder field name completion
  • Specify the fields' parameters.

    ps symfony form builder field parameters completion
  • Specify translation keys and domains in applications that require internationalization and make use of the Translation component.

    ps symfony form translation completion

Code navigation for forms

To navigate to the declaration of a field, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click (for Windows and Linux) or ⌘+Click (for macOS) the usage.
ps symfony form navigate field definition
Last modified: 18 March 2019