Skip to content

Latest commit

 

History

History
193 lines (177 loc) · 4.16 KB

collection.md

File metadata and controls

193 lines (177 loc) · 4.16 KB

Collection

Option source Option name Value type Default Value
Options
  • collection_glue
  • string
  • ' '
Default Column Options Extension
  • label
  • field_mapping
  • display_order
  • string
  • array
  • integer|null
  • $column->getName()
  • array($column->getName())
  • null
Value Format Column Options Extension
  • value_glue
  • value_format
  • empty_value
  • string|null
  • string|Closure|null
  • string
  • null
  • null
  • " " (empty string)
Form Extension
  • editable
  • form_options
  • form_type
  • boolean
  • array
  • array
  • false
  • array()
  • array()

Usage example

Input class

class User
{
    /* @var string */
    public $name;

    /* @var array */
    public $roles
}

======

Example 1

Column Configuration

$datagrid->addColumn('roles', 'collection');

Input

$user = new User();
$user->addRole('admin');
$user->addRole('moderator');
$user->addRole('user');

Output

admin,user,moderator

======

Example 2

Column Configuration

$datagrid->addColumn('user_roles', 'collection', array(
    'field_mapping' => array(
        'roles'
    ),
    'collection_glue' => '|'
));

Input

$user = new User();
$user->addRole('Admin');
$user->addRole('Moderator');
$user->addRole('User');

Output

Admin|Moderator|User

======

Example 3

Column Configuration

$datagrid->addColumn('user_roles', 'text', array(
    'field_mapping' => array(
        'name',
        'roles'
    ),
    'collection_glue' => ',',
    'editable' => true,
    'form_options' => array( // Optional option used to configure forms used to edit fields
        'name' => array(
            'label' => 'Name',
            'required' => false
        ),
        'roles' => array(
            'label' => 'Roles'
            'required' => true
        )
    ),
    'form_types' => array( // Optional option used to change form types used to edit fields
        'name' => 'text',
        'surname' => 'text'
    )
));

======