Skip to content

Add getter and setter in the section on basic form options #16925

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

Merged
merged 1 commit into from
Jul 1, 2022
Merged
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
28 changes: 28 additions & 0 deletions reference/forms/types/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ The actual default value of this option depends on other field options:

.. include:: /reference/forms/types/options/form_attr.rst.inc

``getter``
~~~~~~~~~~

**type**: ``callable`` **default**: ``null``

When provided, this callable will be invoked to read the value from
the underlying object that will be used to populate the form field.

More details are available in the section on :doc:`/form/data_mappers`.

.. versionadded:: 5.2

Form mapping callbacks were added in Symfony 5.2.

.. include:: /reference/forms/types/options/help.rst.inc

.. include:: /reference/forms/types/options/help_attr.rst.inc
Expand Down Expand Up @@ -112,6 +126,20 @@ The actual default value of this option depends on other field options:

.. include:: /reference/forms/types/options/required.rst.inc

``setter``
~~~~~~~~~~

**type**: ``callable`` **default**: ``null``

When provided, this callable will be invoked to map the form value
back to the underlying object.

More details are available in the section on :doc:`/form/data_mappers`.

.. versionadded:: 5.2

Form mapping callbacks were added in Symfony 5.2.

.. include:: /reference/forms/types/options/trim.rst.inc

.. include:: /reference/forms/types/options/validation_groups.rst.inc
Expand Down