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

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 19 2025 21:33:20
Script start
Timing: Jan 19 2025 21:33:20
Module start 'layout'
Timing: Jan 19 2025 21:33:20
Module start 'content'
Timing: Jan 19 2025 21:33:20
Module end 'content'
Timing: Jan 19 2025 21:33:20
Script end

Main resources:

Total runtime0.0170 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.0059 589.0547152.6094
Module start 'layout' 0.00590.0032 741.664139.4141
Module start 'content' 0.00910.0058 781.078197.3047
Module end 'content' 0.01490.0021 878.382842.3047
Script end 0.0170  920.6875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.6962140.0002
Check MTime0.00116.5793140.0001
Mysql Total
Database connection0.00073.861510.0007
Mysqli_queries0.002917.254230.0010
Looping result0.00000.075710.0000
Template Total0.00169.310.0016
Template load0.00084.551110.0008
Template processing0.00084.437610.0008
Override
Cache load0.00053.192910.0005
General
dbfile0.00031.515280.0000
String conversion0.00000.036440.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