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.