Skip to content

Commit 7edc134

Browse files
author
Aitor Brazaola
committed
Added custom list field docs.
1 parent 315201e commit 7edc134

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

docs/custom_list_field.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
11
# Creating a custom list field
2+
3+
In case you want to write your own list field column rendered you need to implement
4+
`LIN3S\AdminBundle\ListFields\ListFieldType`. The `render()` method is expected to return an already escaped
5+
string, can be HTML but be careful as it will be printed in the list without been escaped.
6+
7+
ListFieldTypes are usually generic and need to be associated with an entity in the configuration.
8+
9+
1. Create a new class implementing `LIN3S\AdminBundle\ListFields\ListFieldType`
10+
1. Add the class to Dependency Container with `lin3s_admin.list_field_type` tag name and the desired alias.
11+
1. Reference the created service with the alias in the property `type` of list > field > field_name of your `admin.yml`
12+
13+
## Header function
14+
15+
You can handle the header representation of the column within this function, these are the parameters available:
16+
* options: Array with the name of the field.
17+
* configuration: The configuration.
18+
19+
## Render function
20+
21+
You can handle the header representation of the row within this function, these are the parameters available:
22+
* entity: The entity to represent in the row.
23+
* options: Array with the options declared in admin.yml
24+
* configuration: The configuration.
25+
26+
## Translation
27+
28+
Translating header or rendered row content is possible adding the argument `"@translator.default"` to receive an
29+
instance of translator ready to use.

0 commit comments

Comments
 (0)