Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Documented label_format option#4489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
label_format | ||
~~~~~~~~~~~~ | ||
.. versionadded:: 2.6 | ||
The ``label_format`` option was introduced in Symfony 2.6. | ||
**type**: ``string`` **default**: ``null`` | ||
This allows to change the label for a field. You have access to 2 variables: | ||
``%name%`` and ```%id%``. The ``%id%`` is unique for each field and contains | ||
the complete path to and the field name, the ``%name%`` contains just the field | ||
name. | ||
When using translation keys as labels, you often end up with duplicated labels. | ||
For instance, ``registration_first_name`` and ``profile_first_name``. To avoid | ||
this, you can use the label format:: | ||
// ... | ||
$formBuilder | ||
->add('registration', new RegistrationType(), array( | ||
'label_format' => 'form.person.%name%', | ||
)) | ||
->add('profile', new ProfileType(), array( | ||
'label_format' => 'form.person.%name%', | ||
)) | ||
; | ||
The option is inherited to the child types. With the code above, the | ||
``first_name`` field of both forms will have the ``form.person.first_name`` | ||
label. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. it found it a very difficult option to describe, I'm open for other suggestions! |
Uh oh!
There was an error while loading.Please reload this page.