Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 1.34 KB

custom_list_field.md

File metadata and controls

29 lines (20 loc) · 1.34 KB

Creating a custom list field

In case you want to write your own list field column rendered you need to implement LIN3S\AdminBundle\ListFields\ListFieldType. The render() method is expected to return an already escaped string, can be HTML but be careful as it will be printed in the list without been escaped.

ListFieldTypes are usually generic and need to be associated with an entity in the configuration.

  1. Create a new class implementing LIN3S\AdminBundle\ListFields\ListFieldType
  2. Add the class to Dependency Container with lin3s_admin.list_field_type tag name and the desired alias.
  3. Reference the created service with the alias in the property type of list > field > field_name of your admin.yml

Header function

You can handle the header representation of the column within this function, these are the parameters available:

  • options: Array with the name of the field.
  • configuration: The configuration.

Render function

You can handle the header representation of the row within this function, these are the parameters available:

  • entity: The entity to represent in the row.
  • options: Array with the options declared in admin.yml
  • configuration: The configuration.

Translation

Translating header or rendered row content is possible adding the argument "@translator.default" to receive an instance of translator ready to use.