Radio buttons within forms

Author Message

Paul Forsyth

Wednesday 16 April 2003 12:07:17 am

Im having difficult using radio buttons from within forms and mapping them to attributes.

I have a form that will email comments and information from a user to me. Standard information collector stuff. Most of the form elements I am rendering using code such as:

{attribute_edit_gui attribute=$node.data_map.message}

The trouble comes when using radio buttons. There isnt a
datatype for radio buttons - the closest seems to be either checkbox or enum... so using a function like attribute_edit_gui isnt possible.

A workaround was to create an attribute, find the value in the database corresponding to that attribute and put this into the name value for the list of radio buttons, eg:

<input type="radio" name="ContentObjectAttribute_ezstring_data_text_908" value="Accounts">Accounts

<input type="radio" name="ContentObjectAttribute_ezstring_data_text_908" value="Sales">Sales

But there must be an easier way to do this. What is the best way to handle radio buttons from within forms?

Thanks

Paul

Jan Borsodi

Wednesday 16 April 2003 1:29:15 am

Had you used enum you would been able to get radiobuttons by choosing it in the class edit.

Using other datatypes (int,string) requires some custom template code. If you know the identifier of the attribute you can access it directly and generate the radioboxes.

Example:
{let myattribute=$node.data_map.myidentifier}
{section name=Radio loop=array('Accounts','Sales')}
<input type="radio" name="ContentObjectAttribute_ezstring_data_text_{$myattribute.id}" value="{$:item}">{$:item}</input>
{/section}
{/let}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Forsyth

Wednesday 16 April 2003 1:51:47 am

Thanks Jan,

I tried out both methods.

I didn't realise that by selecting the enum to be a checkbox i would get radio buttons... Maybe the text needs modified as there is a checkbox datatype.

When i tried attribute_edit_gui the design format it displays wasnt to my liking so I used your second method as ive kept the attribute as a non-enum. Using a enum and going into it to pull out elements for my own design would have been messier code. but each to their own. Im still getting used to form building within ez3 :)

Thanks again, Jan.

Paul

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 30 2025 19:42:37
Script start
Timing: Jan 30 2025 19:42:37
Module start 'layout'
Timing: Jan 30 2025 19:42:37
Module start 'content'
Timing: Jan 30 2025 19:42:37
Module end 'content'
Timing: Jan 30 2025 19:42:37
Script end

Main resources:

Total runtime0.0269 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1328151.2109
Module start 'layout' 0.00570.0048 739.3438220.6875
Module start 'content' 0.01040.0146 960.0313997.7891
Module end 'content' 0.02500.0018 1,957.820333.9922
Script end 0.0268  1,991.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002810.5876140.0002
Check MTime0.00124.5118140.0001
Mysql Total
Database connection0.00093.267210.0009
Mysqli_queries0.003613.264930.0012
Looping result0.00000.048810.0000
Template Total0.00134.710.0013
Template load0.00103.583910.0010
Template processing0.00031.093810.0003
Override
Cache load0.00072.436910.0007
General
dbfile0.00134.686680.0002
String conversion0.00000.032840.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.0001 secs