Skip to content

Commit 9c7e525

Browse files
committed
Add Complex Field set_header_template method documentation
1 parent bf8fb8d commit 9c7e525

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

documentation/3-complex-field/5-setup-methods.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
You can use the following methods to setup and customize the complex field.
44

5-
`add_fields( $fields )`
5+
`add_fields($fields)`
66

77
This method is identical to Container add_fields method, where `$fields` is an array of fields.
88

@@ -48,3 +48,37 @@ Field::make('complex', 'crb_employee_data')
4848
Field::make('rich_text', 'description'),
4949
))
5050
```
51+
52+
`set_header_template($template)`
53+
54+
Allows for an Underscore template to be used in the fields group header.
55+
56+
The passed `$template` can also be a [callback](http://php.net/manual/en/language.types.callable.php).
57+
58+
Example usage:
59+
60+
```php
61+
->add_fields('passenger', array(
62+
Field::make('text', 'name'),
63+
Field::make('text', 'years'),
64+
))
65+
->set_header_template('
66+
<# if (name) { #>
67+
Passenger: {{ name }} {{ years ? "(" + years + ")" : "" }}
68+
<# } #>
69+
')
70+
->add_fields('driver', array(
71+
Field::make('text', 'name'),
72+
Field::make('text', 'drivers_license_id'),
73+
Field::make('image', 'picture'),
74+
))
75+
->set_header_template('
76+
<# if (name && drivers_license_id) { #>
77+
<# if (picture) { #>
78+
<img src="{{ _models.picture.get("url") }}" width="18" height="18">
79+
<# } #>
80+
81+
Driver: {{ name }}, {{ drivers_license_id }}
82+
<# } #>
83+
')
84+
```

0 commit comments

Comments
 (0)