Yii Framework Forum: Custom Id For Form Fields - Yii Framework Forum

Jump to content

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

Custom Id For Form Fields Custom id for form fields Rate Topic: -----

#1 User is offline   PLaney 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 01-July 12

Posted 13 May 2013 - 07:51 PM

Hi,

I would like to be able to assign a custom id for a checkbox form field.
I'm using bootstrap and bootstrap booster.


<?php echo $form->checkBoxListInlineRow($data, 'xx_enabled', array('xx name'), array('class'=>'xx-clas', 'labelCss'=>'dd-show' )); ?>



Any help would be appreciated.

Paul.
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,637
  • Joined: 04-March 10
  • Location:UK

Posted 14 May 2013 - 03:18 AM

Does this not work?
<?php echo $form->checkBoxListInlineRow($data, 'xx_enabled', array('xx name'),
        array('class'=>'xx-clas', 'labelCss'=>'dd-show', 'id'=>'your-id')); ?>

0

#3 User is offline   PLaney 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 01-July 12

Posted 14 May 2013 - 06:08 PM

unfortunately not.
0

#4 User is offline   sefburhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 08-February 12
  • Location:islamabad

Posted 17 May 2013 - 02:00 AM

View PostPLaney, on 13 May 2013 - 07:51 PM, said:

Hi,

I would like to be able to assign a custom id for a checkbox form field.
I'm using bootstrap and bootstrap booster.


<?php echo $form->checkBoxListInlineRow($data, 'xx_enabled', array('xx name'), array('class'=>'xx-clas', 'labelCss'=>'dd-show' )); ?>



Any help would be appreciated.

Paul.


define your custom Id in respected model and get it here like other attributes of Model as for bootstrap you need both $model and attribute
something like
in your model inside class
public $custom_id;
public function rules() {
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('custom_id', 'safe'),
);
}

in view

<?php echo $form->checkBoxListInlineRow($data, 'custom_id', array(''), array('class'=>'xx-clas', 'labelCss'=>'dd-show' )); ?>

Enjoy :D
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