10000 feature #4085 [Component][Forms] add missing features introduced in 2… · symfony/symfony-docs@d3b5ba2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3b5ba2

Browse files
committed
feature #4085 [Component][Forms] add missing features introduced in 2.3 (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Component][Forms] add missing features introduced in 2.3 | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#6522) | Applies to | all | Fixed tickets | #2969 - [x] use ``submit()`` instead of ``bind()`` to manually submit a form - [x] configure method and action of a form - [ ] ~~render a form's start and its end separately~~ (see [the comment](#4085 (comment))) - [ ] configure buttons Commits ------- 33f6422 [Forms] add missing features being new in 2.3
2 parents c8a32c5 + 33f6422 commit d3b5ba2

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

book/forms.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ possible paths:
273273
from being able to hit the "Refresh" button of their browser and re-post
274274
the data.
275275

276+
.. seealso::
277+
278+
If you need more control over exactly when your form is submitted or which
279+
data is passed to it, you can use the :method:`Symfony\\Component\\Form\\FormInterface::submit`
280+
for this. Read more about it :ref:`in the cookbook <cookbook-form-call-submit-directly>`.
281+
276282
.. index::
277283
single: Forms; Multiple Submit Buttons
278284

components/form/introduction.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Behind the scenes, this uses a :class:`Symfony\\Component\\Form\\NativeRequestHa
7878
object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or
7979
``$_GET``) based on the HTTP method configured on the form (POST is default).
8080

81+
.. seealso::
82+
83+
If you need more control over exactly when your form is submitted or which
84+
data is passed to it, you can use the :method:`Symfony\\Component\\Form\\FormInterface::submit`
85+
for this. Read more about it :ref:`in the cookbook <cookbook-form-call-submit-directly>`.
86+
8187
.. sidebar:: Integration with the HttpFoundation Component
8288

8389
If you use the HttpFoundation component, then you should add the
@@ -489,6 +495,43 @@ as this is, it's not very flexible (yet). Usually, you'll want to render each
489495
form field individually so you can control how the form looks. You'll learn how
490496
to do that in the ":ref:`form-rendering-template`" section.
491497

498+
Changing a Form's Method and Action
499+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
500+
501+
.. versionadded:: 2.3
502+
The ability to configure the form method and action was introduced in
503+
Symfony 2.3.
504+
505+
By default, a form is submitted to the same URI that rendered the form with
506+
an HTTP POST request. This behavior can be changed using the :ref:`form-option-action`
507+
and :ref:`form-option-method` options (the ``method`` option is also used
508+
by ``handleRequest()`` to determine whether a form has been submitted):
509+
510+
.. configuration-block::
511+
512+
.. code-block:: php-standalone
513+
514+
$formBuilder = $formFactory->createBuilder('form', null, array(
515+
'action' => '/search',
516+
'method' => 'GET',
517+
);
518+
519+
// ...
520+
521+
.. code-block:: php-symfony
522+
523+
// ...
524+
525+
public function searchAction()
526+
{
527+
$formBuilder = $this->createFormBuilder('form', null, array(
528+
'action' => '/search',
529+
'method' => 'GET',
530+
));
531+
532+
// ...
533+
}
534+
492535
.. _component-form-intro-handling-submission:
493536

494537
Handling Form Submissions

cookbook/form/direct_submit.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ submissions::
3737

3838
To see more about this method, read :ref:`book-form-handling-form-submissions`.
3939

40+
.. _cookbook-form-call-submit-directly:
41+
4042
Calling Form::submit() manually
4143
-------------------------------
4244

reference/forms/types/form.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ on all types for which ``form`` is the parent type.
4848
Field Options
4949
-------------
5050

51+
.. _form-option-action:
52+
5153
.. include:: /reference/forms/types/options/action.rst.inc
5254

5355
.. include:: /reference/forms/types/options/by_reference.rst.inc
@@ -96,6 +98,8 @@ The actual default value of this option depends on other field options:
9698

9799
.. include:: /reference/forms/types/options/max_length.rst.inc
98100

101+
.. _form-option-method:
102+
99103
.. include:: /reference/forms/types/options/method.rst.inc
100104

101105
.. _reference-form-option-pattern:

0 commit comments

Comments
 (0)
0