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

Document how to validate associations #3314

Closed
Labels
ValidatoractionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)
@webmozart

Description

@webmozart

There is currently little to no prose documentation about validating associations (apart from theValid reference docs), both in the Validator documentation and in the Form documentation.

The Validator documentation should mention that cascaded validation needs to be activated actively for the associations of an object:

Annotations:

/** * @Assert\Valid */private$author;

YAML:

properties:author:        -Valid:~

XML:

<propertyname="author">    <constraintname="Valid" /></property>

When applied to traversable relations (i.e. an array or a collection object), the relation will be traversed by default. Each object in the collection will be validated as well. This can be deactivated by setting the "traverse" option tofalse.

Deep traversal (e.g. in multi-level arrays) can be enabled by setting the "deep" option totrue.

If you don't want to constrain a relationship with "Valid", but still validate the related object in the Form component, you can set the "cascade_validation" option to true on the root form:

$resolver->setDefaults(array('cascade_validation' =>true,));

Constraints set using the "constraints" option willalways be validated for nested forms, regardless of the "cascade_validation" setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ValidatoractionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)

    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