prevent empty attribute strings in form input controls

<?php echo CHtml::checkBox('', $_GET['location'], array('value'=>'')); ?>

As you can see here I made the ‘name’ and ‘value’ attributes empty, however it still generates these attributes in the html (name="" value="").

How can I prevent it from generating these attributes?

Anyone able to advise?

Can someone help me with this please? :)

I think your options are to either implement the html yourself or to override CHtml::checkBox() and CHtml::inputField().


um, you can remove that form field completely, or u can check in ur model beforeSave if the attribute is empty, it it is then re-assign it to null.

Cheers guys. I think the best option is to implement the HTML myself, although I do think the attributes should not be generated if you set the value to ‘false’.