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

[3.0] [Form] Inconsistency between isValid() and the "valid" template variable #7737

Closed
@webmozart

Description

@webmozart

I'm calling out for you to decide how to resolve the inconsistency between theForm::isValid() method and thevalid variable available in the template:

  • isValid() returnsfalse if a form was not submitted. This way it is possible to write concise controller code:
$form =$this->createForm(...);$form->handleRequest($request);if ($form->isValid()) {// only executed if the form is submitted AND valid}
  • valid containstrue if a form was not submitted. This way it is possible to rely on this variable for error styling of a form.
<div{%ifnotform.vars.valid %}class="error"{%endif %}>

We have two alternatives for resolving this problem:

  1. Leave the inconsistency as is.
  2. MakeisValid() returntrue if a form was not submitted (consistent withvalid)
  3. Revert to the 2.2 behavior of throwing an exception ifisValid() is called on a non-submitted form (not consistent withvalid).

Both 2. and 3. will require additional code in the controller:

$form =$this->createForm(...);$form->handleRequest($request);if ($form->isSubmitted() &&$form->isValid()) {// only executed if the form is submitted AND valid}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp