Skip to content

Commit 06b9e8a

Browse files
committed
#6 Improve documentation
1 parent 8bb4855 commit 06b9e8a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,28 @@ public function fields()
3434
'projectId' => config('unlayer.project_id'),
3535

3636
// optional
37-
'templateId' => config('unlayer.newsletter_template_id'), // Used only if bound attribute is empty (e.g. $newsletter->design)
38-
'displayMode' => 'email', // "email"|"web". Default value: "email"
39-
'locale' => app()->getLocale(), // Locale for Unlayer UI
37+
'templateId' => config('unlayer.newsletter_template_id'), // Used only if bound attribute ('design' in this case) is empty.
38+
'displayMode' => 'web', // "email" or "web". Default value: "email"
39+
'locale' => 'es', // Locale for Unlayer UI. Default value: application’s locale.
4040
]),
4141
];
4242
}
4343
```
4444

4545
### Options
4646
- `->config(array|callable $config)`: Specify [Unlayer config](https://docs.unlayer.com/docs/getting-started#section-configuration-options).
47-
- `->savingCallback(?callable $callback)`: Specify callback on saving a Model. Useful to store HTML result HTML code.
4847
- `->height(string $height)`: Set height of the editor (with units). E.g. '1000px' (800px by default).
48+
- `->savingCallback(?callable $callback)`: Specify a callback to call on before Model saving. Useful to store generated HTML code (to a Model or as a file).
4949

50-
50+
Example of using `savingCallback`:
51+
```php
52+
Unlayer::make('Design')->config([
53+
'projectId' => config('unlayer.project_id'),
54+
])
55+
->savingCallback(function (NovaRequest $request, $attribute, Newsletter $newsletterModel, $htmlFieldName) {
56+
$newsletterModel->html = $request->input($htmlFieldName);
57+
}),
58+
````
5159
### Changelog
5260

5361
Please see [Releases](https://github.com/InteractionDesignFoundation/nova-unlayer-field/releases) for more information on what has changed recently.

0 commit comments

Comments
 (0)