I am trying to validate a date field associate to an order (drupal commerce module) and the validation is ignored. I have tried with differents type of date validation (Date range, custom php...) and nothing seems to work.

Does field validation works with order fields of drupal commerce?

Thanks,

Comments

g089h515r806’s picture

I have only test it with the entity of drupal core, it works.

g089h515r806’s picture

I have test field validation with Address field in checkout of commerce module, it works very well.

It works with normal field at order edit form page.
It does not work with embed field form, such as address embed in order, field collection embed in a node,
This is bug.

g089h515r806’s picture

Status: Active » Needs review

This is bug of part of field validation, I have fixed it in dev version.

But it still does not works. To make it works correctly, Commerce/AddressField module need provide correctly field level validation using hook_field_widget_error.

Field Collection is a good example of such validation

acrazyanimal’s picture

I think this is the same issue.. if you add an email field to the billing information and type in 'ijsdhfk' for the email, the validation error shows up on the review page. So the error is essentially ignored and the value is accepted into the email field. You are allowed to continue on.

What should happen when the field validation fails as is usual, the user should be redirected back to the form to correct their value. Its interesting that if you make that email field 'required' and leave it blank, then the proper redirection happens back to the form. Also, if you have the account info show up on an anonymous checkout and fill in an improper email value like above, the validation works as it should and you are redirected back to the form properly.

edit: woops, didn't realize this was the field validation issue queue. I had searched commerce and this came up. sorry.

g089h515r806’s picture

Now, This is a bug of commerce/addressfield module,
In field validation beta2, we support two methods to set error message, Commerce need to implement hook_field_widget_error correctly and set the parent array correctly.
I have examined the code of addressfield, and find that it does not set the parent array correctly. field collection module did this job very well, it is a good example for other module to follow.

If a the field widget embeded in another big form, we need set the parent array correctly.

Here is an example of parent array:
array(
0 => 'field_myfield',
1=>'und',
2=>'value',
)

to support a form embed in another form, such as field collection module, need to set the parrent array in this way:
array(
0 => 'field_myparentfield',
1=>'und',
2=>'value',
3=>'field_mychildfield',
4=>'und',
5=>'value',
)

How ever, the parrent array in addressfield module is empty.
Commerce module does not check if form_get_error is not empty, there maybe some code :

If(!empty(form_get_error ())){
prevent continue;
}

Field validation set the error message, but commerce could not find the form element which is the target of the error message, then this error message be skipped.

mrfelton’s picture

mrfelton’s picture

Status: Needs review » Active
geek-merlin’s picture

Issue summary: View changes
Status: Active » Fixed

I found this is fixed now IFF validator is condigured to "Set errors using field API".

So closing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

khan2ims’s picture

I am facing same issue again with latest release 7.x-2.6

toki’s picture

Same issue for me with Commerce 1.13 and Field validation 2.6 (Drupal 7.56)
I have tried a simple validation (minimum length 50 characters on long text field) and the checkout process continues without error.
(tests with or without "Set errors using field API")

toki’s picture

Version: 7.x-2.0-beta1 » 7.x-2.6
Priority: Normal » Major
toki’s picture

Another detail about this issue still unsolved, after checkout the field validation I mentioned in #11 is ignored but later if I try to edit the order as an administrator, the field validation is not ignored anymore and I get the error message about my text field (minimum 50 characters long) (so I have to enter details I would like the customer to write!) Thanks in advance for re-opening this issue and suggest a fix.

geek-merlin’s picture

#11
> tests with or without "Set errors using field API"

So if you experience something different than #8, you might want to open another issue, as only a project owner can reopen.
You might want to provide a good description how to reproduce, as usual, and be prepared to work on it yourself or hire someone, as most volunteer resources go into 8.x these days.