Tbbuttoncolumn - Can Not Access $Data Variable

I am trying to add a TbButtonColumn to a instance of a TbGridView in one of my views as follows:

<?php

&#036;this-&gt;widget('bootstrap.widgets.TbGridView', array(


  	'id' =&gt; 'resource-list',





    'pager' =&gt; array('class'=&gt;'bootstrap.widgets.TbPager', 'displayFirstAndLast'=&gt;true),


    'pagerCssClass' =&gt; 'pagination pagination-centered',





  	'type' =&gt; 'bordered striped',





    //'dataProvider' =&gt; &#036;dataProvider,


    'dataProvider' =&gt; &#036;resource-&gt;search(&#036;pageSize),





    'filter' =&gt; &#036;resource,


  	'emptyText' =&gt; HtmlHelper::alert('&lt;strong&gt;Oops&#33;&lt;/strong&gt; No records found to show'),


  	'template' =&gt; &quot;{items}&#092;n{pager}&quot;,





    'htmlOptions' =&gt; array(


  		'class' =&gt; 'resource-layout',


  		'data-type'=&gt;'g',


  		'data-url' =&gt; &#036;this-&gt;createUrl('resource/list')


  	),





  	'columns' =&gt; array(





      array(


    		'name' =&gt; 'name',


    	),





      array(


    		'name' =&gt; 'keywords',


    		'value' =&gt; '&#036;data-&gt;getLabelledKeywords()',


    		'type' =&gt; 'html'


    	),





      array(


    		'filter' =&gt; Classification::getDDListData(),


    		'name' =&gt; 'classification_id',


    		'value' =&gt; '&#036;data-&gt;classification-&gt;name'


    	),





      array(


    		'header' =&gt; 'Collection',


    		'name' =&gt; 'collection.name',


    	),





      array(


    		    'class' =&gt; 'bootstrap.widgets.TbButtonColumn',


    		    'template' =&gt; '{parent_url} {target_url} {view}',


            


            'viewButtonOptions' =&gt; array('class'=&gt;'resource-view'),





            'buttons'=&gt;array


            (


                'parent_url' =&gt; array


                (


                    'label'=&gt;'Parent Url',


                    'icon'=&gt;'external-link',





                    'options'=&gt;array(


                        'class'=&gt;'colorbox_iframe parent_url',


                        'data-title'=&gt;'',


                        'data-content-type'=&gt;'iframe',


                        'data-href' =&gt; ResourceUrl::getResourceUrlParentLink(&#036;data-&gt;id),


                    ),


                ),





                'target_url' =&gt; array


                (


                    'label'=&gt;'Target Url',


                    'icon'=&gt;'external-link',





                    'options'=&gt;array(


                        'class'=&gt;'colorbox_iframe target_url',


                        'data-title'=&gt;'',


                        'data-content-type'=&gt;'iframe',


                        'data-href' =&gt; ResourceUrl::getResourceUrlTargetLink(808),


                    ),


                ),


            ),


        )


  	)


));

?>

I am trying to add this line ‘data-href’ => ResourceUrl::getResourceUrlParentLink($data->id),

but I am getting an error that the $data variable does not exist. I know that the call to the function is working,as when I hard wire the id, the code works perfectly.

What do I need to do be able to access the record id field for the current row?

Thank you

I don’t think you can access the $data variable from the ‘options’ element without extending the TbButtonColumn class.

Hi BlkRaven,

Thank you your response and link. The article looks like exactly what I will need to do, to get my code to work.

Regards,