You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,33 @@ Translatable::make([
128
128
129
129
Using the code about above the name for the `title` field will be "My title ['en']".
130
130
131
+
### Customizing the rules of a translatable
132
+
133
+
You may use the regular Nova functionality to define rules on the fields inside your Translatable fields collection. However, this will apply those rules to all locales. If you wish to define different rules per locale you can do so on the Translatable collection.
You may also use the more fluent `rulesFor()` method, which allows you to define rules per field per locale.
147
+
148
+
```php
149
+
Translatable::make([
150
+
Text::make('My title', 'title'),
151
+
Trix::make('text'),
152
+
])->rulesFor('title', 'en', 'required')
153
+
->rulesFor('title', 'nl', 'nullable'),
154
+
```
155
+
156
+
There are also methods for update and creation rules called `creationRules()`, `updateRules()`, `creationRulesFor()` and `updateRulesFor()`. They function in the same way as the `rules()` and `rulesFor()` methods.
157
+
131
158
## On customizing the UI
132
159
133
160
You might wonder why we didn't render the translatable fields in tabs, panels or with magical unicorns displayed next to them. The truth is that everybody wants translations to be displayed a bit different. That's why we opted to keep them very simple for now.
0 commit comments