Forums / Developer / Forms - handling events, enum datatypes and information collection?

Forms - handling events, enum datatypes and information collection?

Author Message

Paul Wilson

Sunday 18 May 2003 6:09:44 pm

++ Overall Situation:
I am developing a user feedback / information request form, similar to the one in the SDK documentation (ref: www.ez.no/sdk/tutorials/view/forms).

++Situation 1- Enum Datatype, drop box presentation, information collector:
In the definition of the form object, I have included an enum datatype to allow people to select the topic of their feedback/information request ("please send me information about...","website feedback...", etc)
My aim was for people to select from these options in a drop-down box.

++Problem:
I can't select the enum data element as an "information collector", so when it is displayed in the actual form in the user site, it just shows the default value as text, not the drop-down select box that I'd hoped for.

++Question:
Does anybody know how to do this, or is there a convenient work-around?

To get around the information collector issue, I'd thought of collecting the information from the object attribute definition, and then creating an html drop-box, and then write the result to the relevant attribute of the node attribute. Though then I'm not sure of how to write the result to the attribute. Any ideas?

++Situation 2 - EZ-Native handing of form submit events?
Once a form is submitted, ez seems to reload a new blank version of the form by default.

++Question:
Is there an EZ-native method to handle form submission events, eg something that says "on submit, load node XX"?
If not, are there any other good ways of achieving this outcome?

Many thanks!

Paul Forsyth

Monday 19 May 2003 12:04:04 am

Paul,

#Question 1:

We had a similar problem, discussed within:

http://ez.no/developer/ez_publish_3/forum/developer/radio_buttons_within_forms

This code works well for radio buttons:

{section name=Radio loop=array('1', '2', '3')}
<td>
<input type="radio" name="ContentObjectAttribute_ezstring_data_text
_{$node.data_map.contact.id}" value="{$:item}">{$:item}</input>
</td>
{/section}

You can see whats happening here and use the same code to <select><option> for combo boxes, where '$contact' is our enum attribute of the current node.

#Question 2:

Inside your modified collectedinfomail.tpl make sure this line is set to an appropriate node (ours here is 107):

{set-block scope=root variable=redirect_to_node_id}107{/set-block}

This will redirect the form after submission. We have a thank you article set up for this.

Hope this helps you.

Paul

Paul Wilson

Sunday 25 May 2003 6:04:05 am

Hi Paul,

Thanks for your reply ... it was incredibly helpful!

I've actually messed around a fair bit more to get the <option> version going. I eventually realised that I'd missed the **important clue** on all these approaches ... many useful methods that can be applied to each attribute can be seen used in the datatype code within the standard template (the directory design/standard/templates/content/datatype/edit). So, adapting code from there, I got an option box with the following:

(myenumattribute is the attribute we're interested in developing an option box for)

<select name="ContentObjectAttribute_select_data_enumelement_{$node.data_map.myenumattribute.id}[]">
{section name=EnumList loop=$node.data_map.myenumattribute.content.enum_list}
{section name=ObjectList loop=$node.data_map.myenumattribute.content.enumobject_list show=$node.data_map.myenumattribute.content.enumobject_list}
<option name="ContentObjectAttribute_data_enumelement_{$node.data_map.myenumattribute.id}[]" value="{$EnumList:item.enumelement}" {section show=eq($EnumList:item.enumelement,$EnumList:ObjectList:item.enumelement)}selected="selected"{/section}>{$EnumList:item.enumelement}</option>
{section-else}
<option name="ContentObjectAttribute_data_enumelement_{$node.data_map.myenumattribute.id}[]" value="{$EnumList:item.enumelement}">{$EnumList:item.enumelement}</option>
{/section}
{/section}

Note the way that the loop code gets past the need for the pre-defining the array in the ('1','2','3') manner that you'd used with the radio buttons.

Thanks again.

++Further Question...
The only trick I have yet to resolve is how to post the selected value with the form. For some reason it seems to be left out when the form is submitted.

eZ debug

Timing: Jan 30 2025 07:14:11
Script start
Timing: Jan 30 2025 07:14:11
Module start 'content'
Timing: Jan 30 2025 07:14:11
Module end 'content'
Timing: Jan 30 2025 07:14:12
Script end

Main resources:

Total runtime0.3690 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0176 589.4609370.2578
Module start 'content' 0.01760.0151 959.71881,005.6250
Module end 'content' 0.03270.3363 1,965.34383,896.0859
Script end 0.3689  5,861.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00501.3670200.0003
Check MTime0.00150.3948200.0001
Mysql Total
Database connection0.00080.226310.0008
Mysqli_queries0.254268.89001410.0018
Looping result0.00180.48921390.0000
Template Total0.335891.010.3358
Template load0.00080.229810.0008
Template processing0.334990.768210.3349
Override
Cache load0.00060.161810.0006
Sytem overhead
Fetch class attribute can translate value0.00180.498310.0018
XML
Image XML parsing0.00030.073410.0003
General
dbfile0.00852.3125200.0004
String conversion0.00000.001930.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.0001 secs