[SOLVED] CGridView input field id

Hi,

I need to add ‘id’ attribute to some CGridView input fields, so I can use some JQuery

on those fields.

e.g. text field:

<input id="HariLibur_date" type="text" name="HariLibur[date]">

How do I accomplish this? thank you.

this way:




array(


	'name' => 'abc',

	'value' => '$data->def',

	'htmlOptions'=>array(

		'id' => 'HariLibur_date',

	),

),	



hi tofu2000,

thanks for the reply, but your code generates this:

<td id="HariLibur_tanggal">

while i need the id to be put on the input fields

if you talk about the filter fields in CGridView:




array(

        'name' => 'abc',

        'filter'=>CHtml::textField("HariLibur_date"),

),



Hi Mahdi, your code leads me to the solution I want. Thank you!

here is what my code looks like now:




array(

  'name' => 'tanggal',

  'filter' => CHtml::textField('HariLibur[date]','',array(

    'id' => 'HariLibur_date',

    )),

  ),



it generates:


<input type="text" name="HariLibur[date]" value="" id="HariLibur_date">

I need ‘name=HariLibur[date]’ so the search function can still work.

Can simpler >


'filter' => Chtml::tag('input', array(

	'name'=>'Page[title]',

	'id'=>'MyID',

	'type'=>'text',

	'maxlength'=>10,

)),



  • Thanks alot. Simple and sweet ;)