Documentation » Admin

19. Inline Validation »

« 17. Form Help Messages and Descriptions

18. Field Types

18.1. List and Show Actions

There are many field types that can be used in the list action or show action :

  • array: display value from an array
  • boolean: display a green or red picture dependant on the boolean value
  • date: display a formatted date. Accepts an optional format parameter
  • datetime: display a formatted date and time. Accepts an optional format parameter
  • text: display a text
  • textarea: display a textarea
  • trans: translate the value with a provided catalogue option
  • string: display a text
  • decimal: display a number
  • currency: display a number with a provided currency option
  • percent: display a percentage
  • choice: uses the given value as index for the choices array and displays (and optionally translates) the matching value
  • url: display a link

Theses types accept an editable parameter to edit the value from within the list action. This is currently limited to scalar types (text, integer, url...).


If the SonataIntlBundle is installed in the project some template types will be changed to use localized information.

Option for currency type must be an official ISO code, example : EUR for “euros”. List of ISO codes :

In date and datetime field types, format pattern must match twig’s date filter specification, available at:

More types might be provided based on the persistency layer defined. Please refer to their related documentations.

18.1.1. Choice

// For value `prog` is displayed text `In progress`. The `AcmeDemoBundle` catalogue will be used to translate `In progress` message.
$listMapper->add('status', 'choice', array('choices'=>array('prep'=>'Prepared', 'prog'=>'In progress', 'done'=>'Done'), 'catalogue' => 'AcmeDemoBundle'));

choice filed type also supports multiple values that can be separated by delimiter (default delimiter is a comma ”,”).

// For value `array('r', 'b')` is displayed `text `red | blue`.
$listMapper->add('colors', 'choice', array('multiple'=>true, 'delimiter'=>' | ', 'choices'=>array('r'=>'red', 'g'=>'green', 'b'=>'blue')));

18.1.2. Url

Display url link to external website or controller’s action.


  • hide_protocol: remove protocol part from the link text
  • url: url address (e.g.
  • route name (e.g. acme_demo_homepage)
  • route.parameters: array of route parameters (e.g. array('type'=>'example', 'display'=>'full'))
  • route.absolute: boolean value, create absolute or relative url address based on and route.parameters (defalut false)
  • route.identifier_parameter_name: parameter added to route.parameters, it’s value is an object identifier (e.g. ‘id’) to create dynamic links based on rendered objects.
// Output for value ``: `<a href=""></a>`
$listMapper->add('targetUrl', 'url');

// Output for value ``: `<a href=""></a>`
$listMapper->add('targetUrl', 'url', array('hide_protocol' => true));

// Output for value `Homepage of` : `<a href="">Homepage of</a>`
$listMapper->add('title', 'url', array('url' => ''));

// Output for value `Acme Blog Homepage`: `<a href="">Acme Blog Homepage</a>`
$listMapper->add('title', 'url', array('route' => array('name'=>'acme_blog_homepage', 'absolute'=>true)));

// Output for value `Sonata is great!` (related object has identifier `123`): `<a href="">Sonata is great!</a>`
$listMapper->add('title', 'url', array('route' => array('name'=>'acme_blog_article', 'absolute'=>true, 'parameters'=>array('format'=>'xml'), 'identifier_parameter_name'=>'id')));


Do not use url type with addIdentifier method, because it will create invalid nested urls.

Found a typo? Something is wrong in this documentation? Just fork and edit it!