Information Collection Validation

Author Message

Michael Scofield

Monday 23 June 2008 9:10:01 pm

Hello,

I'm a programmer and I've been working with eZ Publish for 1 month until now.

I created a form following this guide http://ez.no/developer/articles/how_to_create_ez_publish_forms and it's working very fine.

The problem is with validation. I would like to implement my own validation over the form attributes, but it seems to be impossible using eZ Publish. At the moment, we are using only the datatype's validation, but it's not sufficient for our form.

We could implement the validation with javascript before the data is submitted, but this is a mobile phone website and many of the devices don't support javascript. And BTW, validation with Javascript can be easily bypassed by hackers.

How do I proceed now? Any of you experienced guys can give me a tip?

Because for me, the only exit is to forget about eZ Publish information collection and implement my form as the usual way (ugly no?). Or, create different datatypes for each attribute of my form, and implement it's validation in the datatype (to much work for only a single form).

Thank you
Michael

Piotrek Karaś

Monday 23 June 2008 11:15:10 pm

<i>Because for me, the only exit is to forget about eZ Publish information collection and implement my form as the usual way (ugly no?). Or, create different datatypes for each attribute of my form, and implement it's validation in the datatype (to much work for only a single form).</i>

Yup, that's what you do. Custom form module is an answer if you require complete flexibility and custom datatypes will be a choice for structured development (either for edit or collect mode). A middle ground could be a complex datatype that for one class/object attribute will provide all/many necessary fields. Also, whether you want the form to create objects or simply store/send data makes a difference.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Michael Scofield

Wednesday 25 June 2008 6:50:57 pm

Thank you a lot Piotrek!

Sorry for me to be in panic. As you said, the options are custom module, custom datatypes or a complex datatype including all fields. I'll think about which way I'll be heading to implement this form.

Btw, about what you said here:

<i>Also, whether you want the form to create objects or simply store/send data makes a difference. </i>

What I'm trying to implement is a promotion drawing form. There is a "name", an "address", an "e-mail" and a question that must be answered by the internaut (drop down with options).

The validation should be done over this question. Because it's a promotion drawing, we can not let the internaut choose a wrong answer in the drop down list.

Another validation should occur in the e-mail attribute. We can not let duplicate participation, and this should be done by checking if the e-mail is already registered.

And of course, we want this information to be stored as collection itens in the back end of the site. This is very important for us.

The question/answer validation I could do with Javascript. It's not trustable, but is sufficient in this particular case. But because this is a mobile phone website, and most mobile phones doesn't support Javascript (I'm in Japan and devices support for Javascript here are even worst), I can not use it.

Thank you again
Michael Scofield

Jérôme Vieilledent

Monday 30 June 2008 1:21:50 pm

Hi Michael

I would suggest you use eZComponents "UserInput" (http://ezcomponents.org/docs/tutorials/UserInput). It's useful with form validation.

Then, you could create one or several tables to store user data. These datas can be accessed with a class extending eZPersistentObject or ezcPersistentObject, from the front or from the backoffice with a module and custom views

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