diff --git a/form/events.rst b/form/events.rst index f9a59c7cbee..fb74ee49e62 100644 --- a/form/events.rst +++ b/form/events.rst @@ -287,7 +287,7 @@ Creating and binding an event listener to the form:: // checks whether the user has chosen to display their email or not. // If the data was submitted previously, the additional value that is // included in the request variables needs to be removed. - if (true === $user['showEmail']) { + if (isset($user['showEmail']) && $user['showEmail']) { $form->add('email', EmailType::class); } else { unset($user['email']); @@ -383,7 +383,7 @@ Consider the following example of a form event subscriber:: // checks whether the user has chosen to display their email or not. // If the data was submitted previously, the additional value that // is included in the request variables needs to be removed. - if (true === $user['showEmail']) { + if (isset($user['showEmail']) && $user['showEmail']) { $form->add('email', EmailType::class); } else { unset($user['email']);