Yii Framework Forum: CHtml::activeRadioButtonList and default radio checked - Yii Framework Forum

Jump to content

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

CHtml::activeRadioButtonList and default radio checked Rate Topic: -----

#1 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 09 November 2009 - 05:01 AM

How can I say to Yii to check a radiobutton for default when the radiobutton list is rendered?

For activeDropDownList it's easy, but I don't see how to do it with radio button in the documentation.
-1

#2 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 09 November 2009 - 05:44 AM

use the activeRadioButton() it's should check it automatically

<?php echo activeRadioButton($post, 'active'); ?>


where $post is the model and 'active' your attribute (database field)
0

#3 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 09 November 2009 - 06:03 AM

View Postbas_vdl, on 09 November 2009 - 05:44 AM, said:

use the activeRadioButton() it's should check it automatically

<?php echo activeRadioButton($post, 'active'); ?>


where $post is the model and 'active' your attribute (database field)



Uhm no I've to specify which is the default value. Is there a way?
Couse the default value is in a attribute of another model.

I've

$user->priority that use a activeRadioButtonList and the default value of activeRadioButtonList is in $user->config->priority
0

#4 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 16 November 2009 - 11:35 AM

Up please :( How can I check an item for default using Yii?
0

#5 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 16 November 2009 - 12:01 PM

View PostStErMi, on 16 November 2009 - 11:35 AM, said:

Up please :( How can I check an item for default using Yii?


If I understand your problem correctly:
Did you try
$user-setAttribute('priority', $user->config->priority)

before rendering the view?
Assuming $user->config refers to the same model instance.

(not tested)
/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
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