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
Comment #1
pingevt commentedActually, that patch was incomplete and apparently only work with my unique situation. Here is an updated version.
Comment #2
anyadahab commentedThere 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) != '#') {Comment #3
hansrossel commentedComment #4
vasikei 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.
Comment #5
vasikeand 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.
Comment #6
sportel commentedFound this issue, probably about the same problem?
https://drupal.org/node/1467168
Comment #7
anrikun commented@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.
Comment #8
anrikun commentedHere is an updated version.
Comment #9
pcambraThanks 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.
Comment #10
anrikun commentedThank 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).
Comment #11
mibfire commentedanrikun, i have just checked your module and the fieldgroup is missing on the review page.
Comment #12
mibfire commentedK, it works if fields are set in customer display mode!
Comment #13
anrikun commented@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.
Comment #14
mibfire commentedanrikun, np:) thx for your module!
Comment #15
anrikun commentedFYI, 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.
Comment #16
mibfire commentedanrikun, nice to see it is released!:)
Comment #17
anrikun commented@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
Comment #18
mibfire commentedanrikun, i have posted this in issue queue of your module. Could you check? thx
Comment #19
anrikun commentedI will have a look at it but please delete the content of post #16.