Yii Framework Forum: CActiveForm checkBox problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CActiveForm checkBox problem Rate Topic: -----

#1 User is offline   viter 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 21-January 10
  • Location:Ukraine Ivano-Frankivsk

Posted 03 June 2010 - 02:46 AM

Hello everyone.
I have a problemm with CActiveForm checkBox. Namely I can't get rid of a hidden field that it generates.
Can anyone help me with this?
Thanks.
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 03 June 2010 - 06:22 AM

This hidden field is necessary and cannot be removed.

Leave it where it is, wihtout this hidden field the checkbox is now working properly.
0

#3 User is offline   viter 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 21-January 10
  • Location:Ukraine Ivano-Frankivsk

Posted 03 June 2010 - 07:55 AM

Why does it not work then?

echo $form->checkBox($model,'typ',array('class'=>'checkbox','value'=>'admin'));


It just does not send 'admin' when the checkbox is checked. What can be wrong?
0

#4 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 03 June 2010 - 08:44 AM

Without the hidden field is not working when you do CActiveRecord->setAttributes() (if you want to use CActiveRecord).

If the model hase 'typ'=admin in db and you want to unset, it will not unset because nothing is posted and so the attribute will not be set.

The hidden field ensure that will be posted 0 if the checkbox is not checked, and so is possible to use CActiveRecord->setAttributes()
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users