Chtml link

Hi Friends,

I need to pass form field values to Chtml link . I have tried in the below mentioned way but it did not work out. Just i am getting the statement itself instead of field value. Am i doing in the right way ? Looking for suggestions. Even i have tried by adding “js:” in front but it’s not working.

Thanks in advance.

echo CHtml::link('Add Trip Details', Yii::app()->createUrl("driverwagescal/internaldriver/TempIntTripDetails/create",array(







Any help ?

Newbie here.

I have a similar problem.

I wish to POST a form on a page using a CButton or any other column type in a CGridView but the parameters for the post come from the grid columns. I am trying to use htmlOptions but $data is not accessible. I thought this would be easy but I’m having a hard time at this.

Thanks in advance.

Is this the one you are looking for ?




					'htmlOptions' => array('style'=>'width:120px'),




       		  			'view' => array


            	 			'label'=>'View Summary Page',


            	 			'url'=>'Yii::app()->createUrl("/driverwagescal/externaldriver/extDriverWagesRec/view", array("id"=>$data->id))',








		       		 	'update' => array


		            	 'label'=>'Amend Wages Records',


		            	 'url'=>'Yii::app()->createUrl("/driverwagescal/externaldriver/extDriverWagesRec/update", array("id"=>$data->id))',

		            	 'visible'=>'$data->status == 1',







Hello there,

Thanks for responding. I don’t think so. I need to POST the form but the grid is not supplying POST information when using the CButton click.

I have tried just about anything I could find from the forum and class ref docs.

Perhaps I am missing something obvious but I am a newb.


Just a note: I see you can call a JS from the click option for CButton definition. My JS is slim and far from none.

I tried to make an alert with data from a column but that did not work as well. Perhaps its my lack there of but if I could get a JS function to get column data I could call a JS Document.form_id.submit function, no ?


'click'=>"function(){alert( $(this).parent().parent().children(':first-child').text() );}",

Got this from another post; if I had some docs for the grid class I could perhaps get the info I require. Right now the first hidden column I have is not being retrieved.

Still trying…

If anyone can help on this one; much appreciated.



With help from here, and a bunch of others. Would not have got this without this post so hats off to those of the post.


This is how I did it.

First, make a virtual attribute in your model to concat a custom URL you would normally have in a button column url.

private $_update_url=NULL;                

public function getupdate_url()        


   $url = "";             



     $url = Yii::app()->createUrl('client/updateDonation', 

              array('id'=>$this->client_id,  'donation_id'=>$this->id)); 

     $this->_update_url = $url;             


   return $this->_update_url;                     


public function setupdate_url($value)        


   $this->_update_url = $value;        


Then in your grid add this column and hide it easy enough with CSS. The visible property did not work for the column when using the JS function of the Click event.

So here is the button and column. Notice the :nth-child([font="Arial Black"]3[/font]) More specifically the number 3. This is the column where you have your URL. Also in the column you will have to add a class for hiding the td which is not assigned in the grid by default.












                  'click'=>'function(){ document.forms.client_form.action=$(this).parent().parent().children(":nth-child(3)").text(); document.forms.client_form.submit();}'                        



Here is my CSS to hide the header and also to reference the htmlOptions above in the grid column holding the url. Firebug does come in handy. I am assuming that the column could be hidden another way, but this is working for me.



display: none;




display: none;


So with the virtual column that is hidden I can now use the CGridView to POST my form with specific column information to a specific controller action. Hurray!!!

Please post back if you do have another option but I could not find any. Hope this helps someone else and saves them some time.


Any help ?