From 228d73e5796025a36696c69fd7ec7f74708d7d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20ALFAIATE?= Date: Wed, 29 Sep 2021 14:22:29 +0700 Subject: [PATCH] [Form] Document the `hash_property_path` option --- reference/forms/types/password.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index d512be22594..6d87ae57af7 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -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 ` 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 ` + set to ``false``:: + + $builder->add('plainPassword', PasswordType::class, [ + 'hash_property_path' => 'password', + 'mapped' => false, + ]); + Overridden Options ------------------ @@ -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