Skip to content

Latest commit

 

History

History
178 lines (165 loc) · 4.85 KB

action.md

File metadata and controls

178 lines (165 loc) · 4.85 KB

Action

Option source Option name Value type Default Value
Options
  • actions
    • route_name
    • redirect_uri
    • absolute
    • url_attr
    • content
    • parameters_field_mapping
    • additional_parameters
  • array
    • string
    • boolean
    • boolean
    • array|Clousure
    • null|string|Clousure
    • array
    • array
  • array()
    • empty (required)
    • true
    • false
    • array()
    • null
    • array()
    • array()
Default Column Options Extension
  • label
  • field_mapping
  • display_order
  • string
  • array
  • integer|null
  • $column->getName()
  • array($column->getName())
  • null

Usage example

Input class

class User
{
    /* @var int */
    public $identity;

    /* @var int */
    public $fb_id;
}

======

Example 1

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>

======