Forums / Developer / Information Collection Validation

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

eZ debug

Timing: Jan 18 2025 04:19:17
Script start
Timing: Jan 18 2025 04:19:17
Module start 'content'
Timing: Jan 18 2025 04:19:18
Module end 'content'
Timing: Jan 18 2025 04:19:18
Script end

Main resources:

Total runtime1.3354 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0087 587.7344180.8281
Module start 'content' 0.00871.1803 768.5625602.7969
Module end 'content' 1.18900.1463 1,371.3594337.3672
Script end 1.3353  1,708.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.3242210.0002
Check MTime0.00160.1189210.0001
Mysql Total
Database connection0.00140.104510.0014
Mysqli_queries1.253293.84391990.0063
Looping result0.00330.24571970.0000
Template Total1.290796.720.6454
Template load0.00270.198720.0013
Template processing1.288196.456620.6440
Template load and register function0.00020.013910.0002
states
state_id_array0.00180.131110.0018
state_identifier_array0.00220.161620.0011
Override
Cache load0.00180.1313330.0001
Sytem overhead
Fetch class attribute can translate value0.00150.115940.0004
Fetch class attribute name0.00150.114360.0003
XML
Image XML parsing0.00140.101840.0003
class_abstraction
Instantiating content class attribute0.00000.001160.0000
General
dbfile0.00240.1814350.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs