I have commerce installed. I added a text field to the commerce_order. With the field_validation module, I've limited this to certain values. Using this module I've added it to the checkout pane. However, when I submit it, it will not validate. The order is updated with an invalid value.

Based off of these comments and a few others I created a patch.
http://drupal.org/node/1865192
http://drupal.org/node/1348384#comment-6729670

My understanding is we need to validate at the widget level, not just the field level, in order for field_validation module to work. And we need to catch that this way, through commerce_fieldgroup_panes_contents_checkout_form_validate()

Comments

pingevt’s picture

Actually, that patch was incomplete and apparently only work with my unique situation. Here is an updated version.

anyadahab’s picture

There is a typo in the patch. I was able to get it to work when I changed the reference for $id:
if(substr($id, 0, 1) != '#') {
to
if(substr($field_id, 0, 1) != '#') {

hansrossel’s picture

Status: Active » Needs review
vasike’s picture

Priority: Normal » Critical
StatusFileSize
new1.38 KB

i agree with the #2 comment. here is the patch with that correction.

and i think it's critical, as i can go to the next checkout page, even the validation didn't take place.

vasike’s picture

and a new patch that adds an extra check for the validation, the same as for the panes submit function.

still needs some testing and maybe some fixes.

sportel’s picture

Issue summary: View changes

Found this issue, probably about the same problem?
https://drupal.org/node/1467168

anrikun’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
StatusFileSize
new2.25 KB

@vasike
Unfortunately, this doesn't work if there are multiple field group panes on a page.
Actually, it is more complicated than that. It seems that Commerce was not designed to easily accept order fields on checkout panes and relying only on pane callbacks like CFP does is not enough.
As I was in a hurry for a project, I've decided to completely rewrite the module.
I'm posting my module here.
- It supports basic validation + Field Validation.
- It puts errors at the right place.
- It accepts sub field groups inside field group panes.
- It renders fields as items on the review page.

@maintainers:
If you want to use my module for CFP, feel free to do so and I won't publish it.
But if you considerer that it's too different and don't mind that I publish it, I will.
Just let me know. Thanks.

I know that I'm not posting a patch but a different module. Sorry again for that.

anrikun’s picture

StatusFileSize
new2.42 KB

Here is an updated version.

pcambra’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

Thanks for the efforts @anrikun but a zipfile is impossible to review. Feel free to create a new module, but a patch would be much more useful in this scenario.

anrikun’s picture

Thank you for answering @pcambra
I'm ok to create a patch but as it's almost a complete rewrite, I'm not sure it will be easier to review.
By the way, I think that the fact that CFP does not validate fields should be considered as a critical bug (if not a security issue).

mibfire’s picture

anrikun, i have just checked your module and the fieldgroup is missing on the review page.

mibfire’s picture

K, it works if fields are set in customer display mode!

anrikun’s picture

@mibfire: thanks for checking.
I know, it's a by-design change in my version: Commerce displays built-in panes on the review page using Customer display mode and I think fieldgroup panes should do the same then.

mibfire’s picture

anrikun, np:) thx for your module!

anrikun’s picture

FYI, I've just released my version as Commerce Checkout Field Group.

Both modules may be merged in the future, but in the meantime I guess having 2 separate modules is easier to maintain.

mibfire’s picture

anrikun, nice to see it is released!:)

anrikun’s picture

@mibfire:
Your post is now in the wrong place. Please delete its content from here and post it at:
https://www.drupal.org/project/issues/commerce_checkout_field_group

mibfire’s picture

anrikun, i have posted this in issue queue of your module. Could you check? thx

anrikun’s picture

I will have a look at it but please delete the content of post #16.