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.

eZ debug

Timing: Jan 18 2025 10:52:52
Script start
Timing: Jan 18 2025 10:52:52
Module start 'layout'
Timing: Jan 18 2025 10:52:52
Module start 'content'
Timing: Jan 18 2025 10:52:52
Module end 'content'
Timing: Jan 18 2025 10:52:52
Script end

Main resources:

Total runtime0.0153 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 587.9219152.6250
Module start 'layout' 0.00570.0030 740.546939.4609
Module start 'content' 0.00870.0049 780.007893.3359
Module end 'content' 0.01360.0016 873.343838.3047
Script end 0.0152  911.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.2429140.0002
Check MTime0.00127.6522140.0001
Mysql Total
Database connection0.00085.475210.0008
Mysqli_queries0.002516.242930.0008
Looping result0.00000.090610.0000
Template Total0.00138.710.0013
Template load0.00074.439810.0007
Template processing0.00064.257110.0006
Override
Cache load0.00052.953110.0005
General
dbfile0.00106.871380.0001
String conversion0.00000.045340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs