Possible Bug In Client Validation Of Cactiveform

I was creating a CActiveForm with the ClientValidation enabled, but stepped in an error when I wrapped a RadioButtonList inside a UL container.

Whenever I submited the form I get a "field cannot be empty" message, even if the radios were checked.

My form:




$form=$this->beginWidget('CActiveForm', array(

 'id'=>'enrollment-form',

 'enableClientValidation'=>true,


 'clientOptions'=>array(

     'inputContainer'=>'ul',

     'validateOnSubmit'=>true,

 ),

));

And one of the RadioButtonLists I use:


<div id="drinks">

  <?php echo $form->label($model,'drink_id',array('class' => 'title')); ?>                

  <?php echo $form->radioButtonList($model,'drink_id', CHtml::listData($drinks, 'id', 'name'), array('container'=>'ul', 'template' => '<li class="radio_row">{input}{label}</li>','separator' => '')); ?>                

  <?php echo $form->error($model,'drink_id'); ?>

</div>

Was I making something wrong?

I studied the code of the jquery.yiiactiveform.js and found that my problem was that in the function that gets the value of the inputs, the value was not taken correctly, because the ID used to identify the inputs was not set in a span, or in the checkboxes/radios themselves (the id was set in the UL container I defined):




var getAFValue = function (o) {

    var type,

        c = [];

    if (!o.length) {

        return undefined;

    }

    if (o[0].tagName.toLowerCase() === 'span') {

        o.find(':checked').each(function () {

            c.push(this.value);

        });

        return c.join(',');

    }

    type = o.attr('type');

    if (type === 'checkbox' || type === 'radio') {

        return o.filter(':checked').val();

    } else {

        return o.val();

    }

};

So I solved this adding || o[0].tagName.toLowerCase() === ‘ul’:


var getAFValue = function (o) {

    var type,

        c = [];

    if (!o.length) {

        return undefined;

    }

    if (o[0].tagName.toLowerCase() === 'span' || o[0].tagName.toLowerCase() === 'ul') {

        o.find(':checked').each(function () {

            c.push(this.value);

        });

        return c.join(',');

    }

    type = o.attr('type');

    if (type === 'checkbox' || type === 'radio') {

        return o.filter(':checked').val();

    } else {

        return o.val();

    }

};

Maybe I was just making some mistake and this solution is just a crappy workaround… but maybe this is just a bug ¿?