Forums / Setup & design / Designing a Form

Designing a Form

Author Message

Rui Pedro Santos

Wednesday 12 December 2007 11:21:49 am

I would like to design a form that would gather information from an anonymous user (validating this info), save this info in the database and send a customized e-mail with the information gathered.

Could someone point me out the best way to do this? I know I can define the content class for the form structure but I don't know how to flesh out the form capture screen base on the content class and also how to validate and send an e-mail during the form processing pipeline.

Thank you.

Karl Latiss

Wednesday 12 December 2007 7:18:52 pm

Use formbuilder and save yourself the time.

http://www.designit.com.au/solutions/ez_publish_form_builder

Atvert Systems
http://www.atvert.com.au

Piotrek Karaś

Wednesday 12 December 2007 10:35:27 pm

If you want to accomplish that by yourself, you would need to study eZ a bit one way, or the other.

The default way is to create a class that would collect information (info collector flag of a class attribute). More info:
http://ez.no/doc/ez_publish/technical_manual/3_10/concepts_and_basics/content_management/information_collection
You don't worry that much about validation in such case, it's taken care of if you use built-in attribute data types.

Alternatively, you may prepare your own extension with a module/view for displaying/receiving data and deal with everything on your own. That requires more knowledge and also PHP programming.

--
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

Rui Pedro Santos

Thursday 13 December 2007 1:49:32 am

I know how to setup a class for doing form collection and setting up a template to show the form (based on the admin edit page from ez).
I've 3 problems to solve:
1. How to override the way input errors are shown?
2. The edit page has a logic of creating drafts and a cancel button when you quit... how can I bypass this to have a real form (one click submit, go away to dismiss)?
3. How to send the e-mail in the end?

We might have taken the wrong approach to begin with...

Thanks for your help

Piotrek Karaś

Thursday 13 December 2007 12:49:40 pm

1. What exactly do you want to change about validation messages?
2. This one actually I don't know out of the box, but I'm sure enough it would be possible if you study the templates. Out of curiosity, what is wrong about that confirmation behavior?
3. Where should the e-mail go? Look at the settings/collect.ini file configuration options.

--
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

Rui Pedro Santos

Thursday 13 December 2007 1:40:29 pm

First of all thanks for your help.

1. The validations I want are a little bit complex (field depending on other fields and such);
2. The fact that most of the users will simply take the trouble the click on the cancel button and my experience shows me that after a while things start going wrong when the draft are not properly cancelled (maybe there is a way to do this automagically)?
3. The e-mail can be defined in the settings file but it has to follow a specific template

Right now I've the forms implemented with the validations and sending the e-mail as required. But to fulfill the requirement the info should also be saved in the database. Another way to do it if somebody knows how would be to call PHP code to save the data in the database?

Thank again for your input.

Piotrek Karaś

Thursday 13 December 2007 2:12:29 pm

The first point is already, in my opinion, reason good enough to move towards own dedicated form extension. It might be possible to override default template behavior for collecting info of particular class, but the truth is any serious logical operations, decisions, validation should be performed in PHP rather than in the presentation layer (templates). And information collection mechanism is very handy, but quite simple as the matter of fact.

In such case, I'd create an extension with custom module views that handle form displaying and validation, and a custom persistent dataset (database table) for storing any results. All of your problems will have straightforward solutions then, as long as you can handle them properly in PHP and as a extenson.

Dig the net and ez.no if you need more info on info on the above.
Good luck!

--
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

eZ debug

Timing: Jan 19 2025 21:25:44
Script start
Timing: Jan 19 2025 21:25:44
Module start 'content'
Timing: Jan 19 2025 21:25:44
Module end 'content'
Timing: Jan 19 2025 21:25:44
Script end

Main resources:

Total runtime0.2793 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0127 588.8516180.8438
Module start 'content' 0.01270.0280 769.6953101.8359
Module end 'content' 0.04070.2385 871.5313530.1250
Script end 0.2792  1,401.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00421.5133200.0002
Check MTime0.00170.6211200.0001
Mysql Total
Database connection0.00080.291510.0008
Mysqli_queries0.183765.78711410.0013
Looping result0.00170.61181390.0000
Template Total0.238085.210.2380
Template load0.00110.410410.0011
Template processing0.236984.819010.2369
Override
Cache load0.00080.304310.0008
Sytem overhead
Fetch class attribute can translate value0.00220.773010.0022
XML
Image XML parsing0.00020.077010.0002
General
dbfile0.029210.4722200.0015
String conversion0.00000.003630.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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