Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Added doc for ControllerTrait::isFormValid#8518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
lyrixx wants to merge1 commit intosymfony:masterfromlyrixx:form-is-valid
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletionsbest_practices/forms.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,6 +197,26 @@ Handling a form submit usually follows a similar template:
// render the template
}

.. versionadded:: 4.1
The ``ControllerTrait::isFormValid()`` method was added in Symfony 4.1.


It's also possible to use a short-cut if the ``ControllerTrait`` is imported:


.. code-block:: php

public function newAction(Request $request)
{
// build the form ...

if ($this->isFormValid($form)) {
// process the form data
}

// render the template
}

There are really only two notable things here. First, we recommend that you
use a single action for both rendering the form and handling the form submit.
For example, you *could* have a ``newAction()`` that *only* renders the form
Expand Down
22 changes: 22 additions & 0 deletionsforms.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,28 @@ your controller::
is called. Otherwise, changes done in the ``*_SUBMIT`` events aren't applied to the
view (like validation errors).


.. versionadded:: 4.1
The ``ControllerTrait::isFormValid()`` method was added in Symfony 4.1.


It's also possible to use a short-cut if the ``ControllerTrait`` is imported:


.. code-block:: php

public function newAction(Request $request)
{
// build the form ...

if ($this->isFormValid($form)) {
// process the form data
}

// render the template
}


This controller follows a common pattern for handling forms and has three
possible paths:

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp