Skip to content

Commit b1654c8

Browse files
authored
Merge pull request #188 from sumocoders/extra-docs
Add docs for label translation
2 parents 31a52d5 + 8339d62 commit b1654c8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/development/forms.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Forms
2+
3+
## Translations
4+
5+
The label for a field will be automatically translated.
6+
7+
```php
8+
...
9+
->add(
10+
'username',
11+
TextType::class,
12+
)
13+
...
14+
```
15+
16+
Will result in
17+
18+
```html
19+
20+
<div class="form-group">
21+
<label for="xxx_form_username" class="form-label">
22+
Username<abbr title="this field is required">*</abbr>
23+
</label>
24+
<input type="text" id="xxx_form_username" name="xxx_form[username]" required="required" class="form-control">
25+
</div>
26+
```
27+
Where `Username` is a translation. So if you want to translate the label, you can do it like this:
28+
29+
```yaml
30+
Username: 'Enter your username'
31+
```

0 commit comments

Comments
 (0)