Skip to content

Mentioned that form related services can now be private #7823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ the ``genders`` parameter value as the first argument to its to-be-created
Make sure the services file is being imported. See :ref:`service-container-imports-directive`
for details.

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define form type services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

First, add a ``__construct`` method to ``GenderType``, which receives the gender
configuration::

Expand Down
4 changes: 4 additions & 0 deletions form/create_form_type_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ The ``extended_type`` key of the tag is the type of field that this extension sh
be applied to. In your case, as you want to extend the ``Symfony\Component\Form\Extension\Core\Type\FileType``
field type, you will use that as the ``extended_type``.

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define type extension services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

.. tip::

There is an optional tag attribute called ``priority``, which
Expand Down
5 changes: 5 additions & 0 deletions form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,16 @@ Define the form type as a service in your configuration files.
)
->addTag('form.type')
;

.. tip::

For more information about defining form types as services, read
:doc:`register your form type as a service </form/form_dependencies>`.

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define form type services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

Now, you can easily use your ``TaskType``::

// e.g. in a controller somewhere
Expand Down
4 changes: 4 additions & 0 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ you need to register it as a service and tag it with :ref:`form.type <dic-tags-f

$container->setDefinition('app.form.friend_message', $definition);

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define form type services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

In a controller that extends the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
class, you can simply call::

Expand Down
4 changes: 4 additions & 0 deletions form/form_dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ Next, register this as a service and tag it with ``form.type``:
->addTag('form.type')
;

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define form type services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

That's it! Your controller - where you create the form - doesn't need to change
at all: Symfony is smart enough to load the ``TaskType`` from the container.

Expand Down
4 changes: 4 additions & 0 deletions form/type_guesser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ creating a service and tagging it as ``form.type_guesser``:
->addTag('form.type_guesser')
;

.. versionadded:: 3.3
Prior to Symfony 3.3, you needed to define type guesser services as ``public``.
Starting from Symfony 3.3, you can also define them as ``private``.

.. sidebar:: Registering a Type Guesser in the Component

If you're using the Form component standalone in your PHP project, use
Expand Down