Skip to content

Commit

Permalink
document the new translatable field config
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Mar 27, 2024
1 parent 9d2fa6d commit fce0cce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ $user->setAttributeTranslated('name', 'Jean-Claude', 'fr');

It is now possible to independently translate the fields defined within a repeater/nestedform formwidget by setting its `translationMode` config to `fields` (see example below)

Note: fields can be marked as translatable either within the Model's `$translatable` array or within the fields.yaml file by adding `translatable: true` to any field config

```php
class User
{
Expand All @@ -265,7 +267,6 @@ class User
public $jsonable = ['data'];
public $translatable = [
'data',
'data[contacts]',
'data[contacts][title]',
];
Expand All @@ -277,13 +278,15 @@ models/user/fields.yaml:
fields:
data[contacts]:
type: repeater (or nestedform)
translatable: true
translationMode: fields
form:
fields:
name:
label: Name
title:
label: Job Title
translatable: true
phone:
label: Phone number
```
Expand Down

0 comments on commit fce0cce

Please sign in to comment.