Validation of radiobuttons and checkboxes

Author Message

Anja Lundin

Thursday 17 March 2005 4:29:13 am

Hi!
I have a question regardning the validation of a form.

I want to validate information from checkboxes and radiobuttons. The user must fill in one alternative before sending the form as an email.

For example: in my class I have a field called customer_type, this is a text field attribute, but (as I read here in the forum) when I show the form on my site I've used:

{let myattribute=$node.data_map.customer_type}
{section name=Radio loop=array('Företagskund','Privatkund')}
<td><b>{$:item}</b><input type="radio" name="ContentObjectAttribute_ezstring_data_text_{$myattribute.id}" value="{$:item}" /></td>
{/section}
{/let}

The problem is that the radiobuttons can be left unchecked. The validation doesn't include my radiobuttons or checkboxes (I've used the same trick for showing checkboxes).

I know that the best thing would have been to create a new datatype that can collect information and is required. No such datatype exists, what I can see (I use version 3.5.0). The enum-attribute can not be set to collect information, and if I change the php-file for the enum-attribute and let it collect information, it still doesn't show radiobuttons with:

{attribute_view_gui attribute=$node.data_map.customer_type}

So my question is: How can I change the collectedinfo_validation.tpl to include my new radiobuttons/checkboxes?

Thanks in advance!
/Anja

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

Frederik Holljen

Monday 21 March 2005 7:09:19 am

Hi,

About the checkbox: The original developer and several other developers considered this proper behavior of the datatype. From their point of view no input is also input. Hence, the required field is meaningless and therefore it doesnt do anything. We have decided to change this behavior for the checkbox field so required means "you are required to check the field". The bug is reported here: http://ez.no/community/bugs/checkbox_does_not_do_validation
The fix should be pretty simple.

Enums will obviously not work as the datatype doesn't support info collection. You should be able to do this with some of the other datatypes that support radiobuttons though.

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 00:25:57
Script start
Timing: Jan 19 2025 00:25:57
Module start 'layout'
Timing: Jan 19 2025 00:25:57
Module start 'content'
Timing: Jan 19 2025 00:25:58
Module end 'content'
Timing: Jan 19 2025 00:25:58
Script end

Main resources:

Total runtime1.0753 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.0469152.6406
Module start 'layout' 0.00500.0022 740.687539.4766
Module start 'content' 0.00721.0667 780.1641535.9297
Module end 'content' 1.07390.0014 1,316.093812.4375
Script end 1.0752  1,328.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2856160.0002
Check MTime0.00120.1134160.0001
Mysql Total
Database connection0.00080.077210.0008
Mysqli_queries1.025895.3995540.0190
Looping result0.00050.0431520.0000
Template Total1.047697.420.5238
Template load0.00230.212920.0011
Template processing1.045297.206320.5226
Template load and register function0.00010.009910.0001
states
state_id_array0.00090.082210.0009
state_identifier_array0.00150.135920.0007
Override
Cache load0.00200.1835210.0001
Sytem overhead
Fetch class attribute can translate value0.00060.052220.0003
Fetch class attribute name0.00110.106740.0003
XML
Image XML parsing0.00110.098320.0005
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00170.1553220.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs