Skip to content

[Form] Document the hash_property_path option #15872

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
Oct 23, 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
30 changes: 30 additions & 0 deletions reference/forms/types/password.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@ with the ``value`` attribute set to its true value only upon submission.
If you want to render your password field *with* the password value already
entered into the box, set this to false and submit the form.

``hash_property_path``
~~~~~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``null``

.. versionadded:: 6.2

The ``hash_property_path`` option was introduced in Symfony 6.2.

If set, the password will be hashed using the
:doc:`PasswordHasher component </security/passwords>` and stored in the
specified property.

Data passed to the form must be a
:class:`Symfony\\Component\\Security\\Core\\User\\PasswordAuthenticatedUserInterface`
object.

.. caution::

To minimize the risk of leaking the plain password, this option can
only be used with the :ref:`"mapped" option <reference-form-password-mapped>`
set to ``false``::

$builder->add('plainPassword', PasswordType::class, [
'hash_property_path' => 'password',
'mapped' => false,
]);

Overridden Options
------------------

Expand Down Expand Up @@ -81,6 +109,8 @@ The default value is ``''`` (the empty string).

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

.. _reference-form-password-mapped:

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

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