8000 [Form][DelegatingValidator] error_bubbling => false doesn't work with date field · Issue #3018 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[Form][DelegatingValidator] error_bubbling => false doesn't work with date field #3018

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
kjaniszewski opened this issue Jan 2, 2012 · 3 comments
Milestone

Comments

@kjaniszewski
Copy link

Hi!

I've just noticied, that error_bubbling set to false for field type 'date' doesn't make any effect.

$builder->add('receipt_time', 'date', array(
'required' => true,
'input' => 'string',
'error_bubbling' => false
));

error for field above are displayed as form errors.

$builder->add('receipt_time', 'text', array(
'required' => true,
'input' => 'string',
'error_bubbling' => false
));

errors from above are displayed correctly as field errors.

Please fix asap.

Best regards
Krzychu

@inmarelibero
Copy link
Contributor

Hi, a few questions:

  1. are you sure about the code you posted? shouldn't
$builder->add('receipt_time', 'text', array(
    'required' => true,
    'input' => 'string',
    'error_bubbling' => false
));

return an error? because, as shown in http://symfony.com/doc/2.0/reference/forms/types/text.html, 'text' field type does not allow the option 'input'

  1. is the form you are building linked to any entity?

  2. are you talking about html5 error popups or symfony error fields displayed after submitting the form?

  3. did you read carefully at http://symfony.com/doc/2.0/reference/forms/types/date.html#input about the difference between 'input' and 'widget' options?

@kjaniszewski
Copy link
Author

Hi!

  1. are you sure about the code you posted? shouldn't

Copy/paste mistake. Of course there was no 'input' while I was testing it.

  1. is the form you are building linked to any entity?

It is linked to Propel objects.

  1. are you talking about html5 error popups or symfony error fields displayed after submitting the form?

I don't use HTML5. I'm talking about symfony error messages after form submission.

  1. did you read carefully at http://symfony.com/doc/2.0/reference/forms/types/date.html#input about the difference between 'input' and 'widget' options?

Yes, I've read it but it is not related to problem with non-working error_bubbling.

Pozdrawiam
Krzysztof Janiszewski

ecenter sp. z o.o.

Domeny, hosting, poczta wideo :: http://www.ecenter.pl ::

Niniejsza wiadomość przekazana została Państwu przez ecenter sp z o.o.
87-100 Toruń, Ul. Goździkowa 2
Zarejestrowana w Sądzie Rejonowym w Toruniu VII Wydział Gospodarczy Krajowego Rejestru Sądowego pod numerem 0000251110 Z kapitałem zakładowym w wysokości 142500zł NIP 956-216-66-73

@tamirvs
Copy link
Contributor
tamirvs commented Feb 2, 2012

It looks like it only occurs from within an embedded form.
In DelegatingValidator, line 88, preg_match is trying to match a mappedPath to the violation's propertyPath.

I've printed those mathcing attempts as preg_match(mappedPath, propertyPath) from both an embedded form and a non-embedded form:

In UserType form (non-embedded) I have a field named birthday of type date:

preg_match(/^data\.birthday\.(?!\w)/, data.birthday)
preg_match(/^data\.birthday\.year(?!\w)/, data.birthday)
preg_match(/^data\.birthday\.month(?!\w)/, data.birthday)
preg_match(/^data\.birthday\.day(?!\w)/, data.birthday)
preg_match(/^data\[birthday\]\.(?!\w)/, data.birthday)
preg_match(/^data\[birthday\]\.year(?!\w)/, data.birthday)
preg_match(/^data\[birthday\]\.month(?!\w)/, data.birthday)
preg_match(/^data\[birthday\]\.day(?!\w)/, data.birthday)
preg_match(/^data\.birthday(?!\w)/, data.birthday) <-- MATCH!

As you can see, the MATCH comes on the correct child field - the birthday field.

In RegistrationForm I have an embedded form named user of type UserType with the same birthday field:

preg_match(/^children\[user\]\[birthday\]\.data\.(?!\w)/, children[user].data.birthday)
preg_match(/^children\[user\]\[birthday\]\.data\.year(?!\w)/, children[user].data.birthday)
preg_match(/^children\[user\]\[birthday\]\.data\.month(?!\w)/, children[user].data.birthday)
preg_match(/^children\[user\]\[birthday\]\.data\.day(?!\w)/, children[user].data.birthday)
preg_match(/^children\[user\]\[birthday\](?!\w)/, children[user].data.birthday)
preg_match(/^children\[user\](?!\w)/, children[user].data.birthday) <-- MATCH!

As you can see here, there is no match for the birthday field, and the match is for the user form.

In mappedPath, the birthday field is children[user][birthday]
In propertyPath, the birthday field is children[user].data.birthday

That's why there's no match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0