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.