Conditional form validation

Author Message

Claudia Kosny

Tuesday 26 September 2006 3:59:12 am

Hi there

I have a form where the user can select between different payment options, e.g. cheque, paypal or credit card. If he selects credit card the fields for card holder, card number, expiry date ... must be filled in as well, otherwise they can be empty.

Is there a way to do this with the EZ form validation? Or can I somehow set up the class definition in such a way that the fields for the credit card details are only required if the option credit card is selected? I am using EZ 3.8.4.

Thanks for any tips

Claudia

Xavier Dutoit

Tuesday 26 September 2006 6:36:44 am

Hi,

Just to be sure: you are storing credit cards info on ez publish or is this an exemple ?

Nothing native. You can create a custom template for the edit and add your business rules in the javascript onsubmit.

If this isn't only ergo/cosmetic, you will have to create a custom event that you'll add in the pre publish workflow to enforce your business rules.

Developing a custom event isn't really difficult, but debuging is a serious pain in the ... good luck and keep us inform !

X+

http://www.sydesy.com

Claudia Kosny

Tuesday 26 September 2006 7:56:33 am

Hi Xavier

Thanks for the answer - I was afraid that there was nothing built in for this but it never hurts to ask. As I do not know much about workflow syet I think I will just post the form to an (yet to write) extension of mine which performs the required validation (Javascript is not sufficient in this case) and then does the publishing.
Regarding the credit card info - it was more of an example. After reading a bit about it I know that this is nothing I would want to do. Another example for conditional validation would be e.g to force the customer to state either his phone number or his fax number - if he has given one I don't need the other.

Greetings from Luxembourg

Claudia

Xavier Dutoit

Tuesday 26 September 2006 8:13:26 am

Hi,

I didn't want to scare you with the workflows, just warn you to not underestimate the debug time ;)

As for the extension, it looks like a good idea. Instead of writing a new one, I'd suggest you to have a look at powercontent from kristof. I don't think it'd be too complicated to add custom validations on his work.

If you want, contact us by email (ez at sydesy dot com ) so we can dig that a wee bit more.

X+

http://www.sydesy.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.