list_field_definition.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. List field definition
  2. =====================
  3. These fields are used to display the information inside the list table.
  4. Example
  5. -------
  6. .. code-block:: php
  7. <?php
  8. namespace Sonata\NewsBundle\Admin;
  9. use Sonata\BaseApplicationBundle\Admin\EntityAdmin;
  10. class PostAdmin extends EntityAdmin
  11. {
  12. protected $list = array(
  13. 'title' => array(),
  14. 'enabled' => array('type' => 'boolean'),
  15. 'tags' => array()
  16. );
  17. public function configureListFields() // optional
  18. {
  19. $this->listFields['summary']->setTemplate('NewsBundle:NewsAdmin:list_summary.twig');
  20. }
  21. }
  22. As you can see, the filter fields are defined by overriding the ``filter_fields``
  23. property and giving each definition an array of options. You can also customize
  24. each field further by overriding the ``configureListFields()`` method, which
  25. is blank in the parent class.
  26. Types available
  27. ---------------
  28. The most important option for each field is the ``type``: The available
  29. types include:
  30. * boolean
  31. * datetime
  32. * decimal
  33. * identifier
  34. * integer
  35. * many_to_one : a link will be added to the related edit action
  36. * string
  37. * text
  38. If no type is set, the ``Admin`` class will use the type defined in the doctrine
  39. mapping definition.
  40. Tweak it!
  41. ---------
  42. It is possible to change the default template by setting a template key in the
  43. definition.
  44. - if the identifier key is set, then the field will be encapsulate by a link to
  45. the edit action