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: docs/usage/forms.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,43 @@ $post->fill([
13
13
]);
14
14
```
15
15
16
+
## Request as array syntax
17
+
16
18
To achieve this structure in your form - to prevent manipulating the form data just to save them. You can use the input name array `[]`[syntax](https://www.php.net/manual/en/faq.html.php#faq.html.arrays).
17
19
18
-
```markup
20
+
```html
19
21
<inputtype="text"name="en[title]" />
20
22
<inputtype="text"name="de[title]" />
21
23
```
22
24
25
+
## Request as plain syntax
26
+
27
+
If you want, you can structure the request inputs in colon notation too. Notice that with this approach the attribute goes first.
28
+
29
+
```html
30
+
<inputtype="text"name="title:en" />
31
+
<inputtype="text"name="title:de" />
32
+
```
33
+
34
+
## Saving the request
35
+
36
+
Both ways are ready to save the translatable attributes to the model without any other modification.
37
+
38
+
```php
39
+
public function update(Request $request, Post $post)
40
+
{
41
+
$post->update($request->all());
42
+
}
43
+
```
44
+
45
+
# Updating the default locale
46
+
47
+
You can update the default locale attributes by accessing the translatable attributes from the model itself.
48
+
49
+
```php
50
+
$post->title = 'My first post'; // Will update the English translatable model
51
+
```
52
+
53
+
```php
54
+
$post->fill(['title' => 'My first post']); // Will update the English translatable model
0 commit comments