IntelliJ IDEA 2022.2 Help

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.

Install the required plugins

This functionality relies on the PHP, Symfony Support, and PHP Annotations plugins that should be installed and enabled in your IDE.

The plugins are available only in IntelliJ IDEA Ultimate.

  1. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  2. Switch to the Marketplace tab and use the search field to find the plugins.

  3. Click Install next to each plugin and restart the IDE if prompted.

Code completion in forms

IntelliJ IDEA 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.

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

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

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

    Symfony form builder translations completion

Code navigation in forms

To navigate to the declaration of a field, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

Navigating to Symfony field definition
Last modified: 29 November 2022