This is the list of built-in field types.
Simplest column type, which basically renders the value at given path as a string.
By default it uses the name of the field, but you can specify the path alternatively. For example:
sylius_grid:
grids:
app_user:
fields:
email:
type: string
label: app.ui.email # each filed type can have a label, we suggest using translation keys instead of messages
path: contactDetails.email
This configuration will display the value from $user->getContactDetails()->getEmail()
.
This column type works exactly the same way as string, but expects DateTime instance and outputs a formatted date and time string.
sylius_grid:
grids:
app_user:
fields:
birthday:
type: datetime
label: app.ui.birthday
options:
format: 'Y:m:d H:i:s' # this is the default value, but you can modify it
Twig column type is the most flexible from all of them, because it delegates the logic of rendering the value to Twig templating engine. You just have to specify the template and it will be rendered with the data
variable available to you.
sylius_grid:
grids:
app_user:
fields:
name:
type: twig
label: app.ui.name
options:
template: :Grid/Column:_prettyName.html.twig
In the :Grid/Column:_prettyName.html.twig
template, you just need to render the value for example as you see below:
<strong>{{ data.name }}</strong>
<p>{{ data.description|markdown }}</p>
Boolean column type expects the value to be boolean and renders a default or custom Twig template.
sylius_grid:
grids:
app_user:
fields:
status:
type: boolean
label: app.ui.status