From 6bed3c77e355aa09a48f50b55e0b1c1debc7600e Mon Sep 17 00:00:00 2001 From: Harm van Tilborg Date: Fri, 6 Jan 2017 09:42:01 +0100 Subject: [PATCH] Made unmapped field example in forms chapter more descriptive --- forms.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/forms.rst b/forms.rst index 334c64e4fa7..be03cf35a9b 100644 --- a/forms.rst +++ b/forms.rst @@ -667,7 +667,8 @@ the choice is ultimately up to you. { $builder ->add('task') - ->add('dueDate', null, array('mapped' => false)) + ->add('dueDate') + ->add('agreeTerms', CheckboxType::class, array('mapped' => false)) ->add('save', SubmitType::class) ; } @@ -677,11 +678,11 @@ the choice is ultimately up to you. The field data can be accessed in a controller with:: - $form->get('dueDate')->getData(); + $form->get('agreeTerms')->getData(); In addition, the data of an unmapped field can also be modified directly:: - $form->get('dueDate')->setData(new \DateTime()); + $form->get('agreeTerms')->setData(true); Final Thoughts --------------