|
2 | 2 |
|
3 | 3 | You can use the following methods to setup and customize the complex field.
|
4 | 4 |
|
5 |
| -`add_fields( $fields )` |
| 5 | +`add_fields($fields)` |
6 | 6 |
|
7 | 7 | This method is identical to Container add_fields method, where `$fields` is an array of fields.
|
8 | 8 |
|
@@ -48,3 +48,37 @@ Field::make('complex', 'crb_employee_data')
|
48 | 48 | Field::make('rich_text', 'description'),
|
49 | 49 | ))
|
50 | 50 | ```
|
| 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