8000 [reference] [form] [options] error_mapping · Issue #6153 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[reference] [form] [options] error_mapping #6153

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HeahDude opened this issue Jan 16, 2016 · 4 comments
Closed

[reference] [form] [options] error_mapping #6153

HeahDude opened this issue Jan 16, 2016 · 4 comments
Labels
hasPR A Pull Request has already been submitted for this issue.

Comments

@HeahDude
Copy link
Contributor

in the given example :

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'error_mapping' => array(
            'matchingCityAndZipCode' => 'city',
        ),
    ));
}

in this reference :

The left side of the error mapping also accepts a dot ., which refers to the field itself. That means that any error added to the field is added to the given nested field instead;

"left side" is actually the wrong side, I mean the "right side"...

@wouterj
Copy link
Member
wouterj commented Jan 16, 2016

It's correct, as shown in this blog post. As far as I understand it, a dot means every violation on any field of this form is mapped to the city field.

As it's a bit unclear (I don't 100% understand it and you were confused as well), I think we should at least add the code example in the blog posts to make things a bit more clear. Can you maybe add this?

@HeahDude
Copy link
Contributor Author

@wouterj I don't understand as this example it is set as default, so all errors for fields of this form are mapped to one field ?

The left side of the error mapping also accepts a dot ., which refers to the field itself. That means that any error added to the field is added to the given nested field instead.

"added to THE field", not the form, weird

@HeahDude
Copy link
Contributor Author

Ok I confirm '.' mapped all unmapped validation rules.
Will do as you suggest

HeahDude added a commit to HeahDude/symfony-docs that referenced this issue Jan 16, 2016
@wouterj wouterj added the hasPR A Pull Request has already been submitted for this issue. label Jan 20, 2016
wouterj added a commit that referenced this issue Feb 6, 2016
This PR was squashed before being merged into the 2.3 branch (closes #6156).

Discussion
----------

[reference] [form] [options] fix #6153

| Q             | A
| ------------- | ---
| Doc fix?        | yes
| New docs?   | no
| Applies to     | 2.3+
| Fixed tickets | #6153

Commits
-------

a15f856 [reference] [form] [options] fix #6153
@HeahDude
Copy link
Contributor Author
HeahDude commented Feb 6, 2016

Hi @wouterj, I've left a comment on the PR.

Once you reviewed it, I think we can close this issue.

@wouterj wouterj closed this as completed in a15f856 Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

2 participants
0