0

I have a checkbox:

echo CHtml::checkBox("My checkbox", true, array());

How do I read its value through Yii? I know there's activeCheckBox which will link the value to a model attribute, but I don't want to create a new model class just to read a single value from a checkbox. Do I have to assign it an ID and get the value with javascript? Seems pretty absurd to me that Yii would have a function to create a checkbox but no way to retrieve its value afterwards… Also, since dynamic attributes don't work in Yii I can't just create an attribute on some other model that I have available.

How are the CHtml::checkBox elements in Yii intended to be used?

Gordon
  • 312,688
  • 75
  • 539
  • 559
moggizx
  • 476
  • 1
  • 5
  • 19
  • the html will contain id and name using CHtml::checkBox(), you can get using javascript or will be post in postdata. – Rakesh kumar Aug 29 '14 at 09:28

1 Answers1

0

just use $_POST['My checkbox'] ;

CHtml::checkBox just generate an input tag for you .

you can open html source and see it .

jiang
  • 170
  • 4
  • I just realized this myself... I guess it was kind of a stupid question. I'm not really into the whole web/PHP/Yii mindset at all, I try to stay away from it as much as possible :) – moggizx Aug 29 '14 at 10:42