From 8093719ee3758b914ee0e4204b4d0fec05f92461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Perrin?= Date: Thu, 20 Mar 2014 14:51:45 +0100 Subject: [PATCH 1/2] Dynamic form modification cookbook: Fix inclusion of code Includes in a code block don't work, replace them with the actual code --- cookbook/form/dynamic_form_modification.rst | 52 ++++++++++++++++++- .../dynamic_form_modification_ajax_js.rst.inc | 25 --------- 2 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 cookbook/form/dynamic_form_modification_ajax_js.rst.inc diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index b963bab1e5d..bd4f60e0165 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -653,7 +653,31 @@ field according to the current selection in the ``sport`` field: {# ... #} {{ form_end(form) }} - .. include:: /cookbook/form/dynamic_form_modification_ajax_js.rst.inc + .. code-block:: html+php @@ -664,7 +688,31 @@ field according to the current selection in the ``sport`` field: end($form) ?> - .. include:: /cookbook/form/dynamic_form_modification_ajax_js.rst.inc + The major benefit of submitting the whole form to just extract the updated ``position`` field is that no additional server-side code is needed; all the diff --git a/cookbook/form/dynamic_form_modification_ajax_js.rst.inc b/cookbook/form/dynamic_form_modification_ajax_js.rst.inc deleted file mode 100644 index 09e255808db..00000000000 --- a/cookbook/form/dynamic_form_modification_ajax_js.rst.inc +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file From 1e8b0d4279694738cd5524206af9ff49c3c6029d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Perrin?= Date: Thu, 20 Mar 2014 14:52:13 +0100 Subject: [PATCH 2/2] Small fixes in code style --- cookbook/form/dynamic_form_modification.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index bd4f60e0165..2add7ddd759 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -116,7 +116,7 @@ the event listener might look like the following:: public function buildForm(FormBuilderInterface $builder, array $options) { // ... - $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){ + $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) { $product = $event->getData(); $form = $event->getForm(); @@ -147,7 +147,8 @@ the event listener might look like the following:: $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData')); } - public function onPreSetData(FormEvent $event){ + public function onPreSetData(FormEvent $event) + { // ... } } @@ -253,7 +254,7 @@ Using an event listener, your form might look like this:: ->add('subject', 'text') ->add('body', 'textarea') ; - $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){ + $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) { // ... add a choice list of friends of the current application user }); } @@ -656,7 +657,7 @@ field according to the current selection in the ``sport`` field: