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 --------------