nuxtech
(Nuxtech)
1
according to input-element
i used CForm::dropdownlist
<select name="MyForm[gender]" id="MyForm_gender">
<option value="0">Gender</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
because it always selected by default with "0" value (not empty).
how i can validate with rules?
thanks
ramin2nt2
(Ramin Mousavy)
2
nuxtech
(Nuxtech)
3
thanks for your suggestion
is there a validation that except "0" as default value.
i mean if its value is not "0", it means not empty.
Angelo
(Angelo)
4
Why not user the prompt element command in your dropdown list call. That way there is no value attached to default
'gender'=>array(
'type'=>'dropdownlist',
'prompt'=>'Please select gender:',
... rest of your stuff
,
or
<?php echo $form->dropDownList($model,'gender', array('0'=>'Male', '1'=>'Female'), array('prompt'=>'Please Select')); ?>
Angelo
(Angelo)
6
no problem. It’s nice to be on the giving end of help once in a while:D
capsuline
(Robinkouwen)
7
Thanks @Angelo
You are indeed the man with a hammer today. Just like your avatar 
Have been struggling for a while trying to find a solution for this.
I was trying all kind of regular expressions. but all this time I just needed