Option source | Option name | Value type | Default Value |
Options |
|
|
|
Default Column Options Extension |
|
|
|
Input class
class User
{
/* @var int */
public $identity;
/* @var int */
public $fb_id;
}
======
Column Configuration
$datagrid->addColumn('actions', 'action', array(
'label' => 'Actions',
'mapping_fields' => array('identity', 'fb_id'),
'actions' => array(
'edit' => array(
'route_name' => '_edit_user',
'parameters_field_mapping' => array('id' => 'identity'),
'url_attr' => array(
'class' => 'btn btn-primary btn-xs',
'title' => 'datagrid.action.edit'
),
'content' => '<span class="glyphicon glyphicon-edit"></span>',
),
'delete' => array(
'route_name' => '_delete_user',
'parameters_field_mapping' => array('id' => 'identity'),
'url_attr' => function($value, $index) {
return array(
'class' => $index,
'title' => 'Delete - ' . $value['id']
);
},
'content' => function($value, $index) {
return 'Delete - ' . $value['id'];
}
),
'facebook' => array(
'url_attr' => function($value, $index) {
return array(
'href' => empty($value['fb_id']) ? '#' : 'https://www.facebook.com/' . $value['fb_id'],
'target' => '_blank'
);
},
'content' => function($value, $index) {
return empty($value['fb_id']) ? ' - ' : 'FB profile';
}
)
)
));
Input
$user = new User();
$user->id = 1;
$user->fb_id = 100000370790515;
# app/config/routing.yml
_edit_user:
path: /user/edit/{id}
defaults: { _controller: FSiDemoBundle:User:edit }
_delete_user:
path: /user/delete/{id}
defaults: { _controller: FSiDemoBundle:User:delete }
Output
<a class="btn btn-primary btn-xs" title="Edit" href="/user/edit/1"><span class="glyphicon glyphicon-edit"></span></a>
<a class="delete" title="Delete - 1" href="/user/delete/1">Delete - 1</a>
<a target="_blank" href="https://www.facebook.com/100000370790515">FB profile</a>
======