I am trying to add a TbButtonColumn to a instance of a TbGridView in one of my views as follows:
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'resource-list',
'pager' => array('class'=>'bootstrap.widgets.TbPager', 'displayFirstAndLast'=>true),
'pagerCssClass' => 'pagination pagination-centered',
'type' => 'bordered striped',
//'dataProvider' => $dataProvider,
'dataProvider' => $resource->search($pageSize),
'filter' => $resource,
'emptyText' => HtmlHelper::alert('<strong>Oops!</strong> No records found to show'),
'template' => "{items}\n{pager}",
'htmlOptions' => array(
'class' => 'resource-layout',
'data-type'=>'g',
'data-url' => $this->createUrl('resource/list')
),
'columns' => array(
array(
'name' => 'name',
),
array(
'name' => 'keywords',
'value' => '$data->getLabelledKeywords()',
'type' => 'html'
),
array(
'filter' => Classification::getDDListData(),
'name' => 'classification_id',
'value' => '$data->classification->name'
),
array(
'header' => 'Collection',
'name' => 'collection.name',
),
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => '{parent_url} {target_url} {view}',
'viewButtonOptions' => array('class'=>'resource-view'),
'buttons'=>array
(
'parent_url' => array
(
'label'=>'Parent Url',
'icon'=>'external-link',
'options'=>array(
'class'=>'colorbox_iframe parent_url',
'data-title'=>'',
'data-content-type'=>'iframe',
'data-href' => ResourceUrl::getResourceUrlParentLink($data->id),
),
),
'target_url' => array
(
'label'=>'Target Url',
'icon'=>'external-link',
'options'=>array(
'class'=>'colorbox_iframe target_url',
'data-title'=>'',
'data-content-type'=>'iframe',
'data-href' => 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