Skip to content

Commit 816abbc

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Form] Example of customizing EnumType labels Add the examples for XML and PHP config Update database.rst
2 parents 7e086b2 + c4de976 commit 816abbc

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

reference/forms/types/enum.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ short) defined somewhere in your application. This enum has to be of type
3434

3535
enum TextAlign: string
3636
{
37-
case Left = 'Left/Start aligned';
38-
case Center = 'Center/Middle aligned';
39-
case Right = 'Right/End aligned';
37+
case Left = 'Left aligned';
38+
case Center = 'Center aligned';
39+
case Right = 'Right aligned';
4040
}
4141

4242
Instead of using the values of the enumeration in a ``choices`` option, the
@@ -52,6 +52,20 @@ This will display a ``<select>`` tag with the three possible values defined in
5252
the ``TextAlign`` enum. Use the `expanded`_ and `multiple`_ options to display
5353
these values as ``<input type="checkbox">`` or ``<input type="radio">``.
5454

55+
The label displayed in the ``<option>`` elements of the ``<select>`` is the enum
56+
name. PHP defines some strict rules for these names (e.g. they can't contain
57+
dots or spaces). If you need more flexibility for these labels, use the
58+
``choice_label`` option and define a function that returns the custom label::
59+
60+
->add('textAlign', EnumType::class, [
61+
'class' => TextAlign::class,
62+
'choice_label' => match ($choice) {
63+
TextAlign::Left => 'text_align.left.label',
64+
TextAlign::Center => 'text_align.center.label',
65+
TextAlign::Right => 'text_align.right.label',
66+
},
67+
]);
68+
5569
Field Options
5670
-------------
5771

session/database.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ First, define a Symfony service for the connection to the Redis server:
5050
# uncomment the following if your Redis server requires a password
5151
# - auth:
5252
# - '%env(REDIS_PASSWORD)%'
53+
54+
# uncomment the following if your Redis server requires a user and a password (when user is not default)
55+
# - auth:
56+
# - ['%env(REDIS_USER)%','%env(REDIS_PASSWORD)%']
5357
5458
.. code-block:: xml
5559
@@ -70,6 +74,12 @@ First, define a Symfony service for the connection to the Redis server:
7074
<call method="auth">
7175
<argument>%env(REDIS_PASSWORD)%</argument>
7276
</call> -->
77+
78+
<!-- uncomment the following if your Redis server requires a user and a password (when user is not default):
79+
<call method="auth">
80+
<argument>%env(REDIS_USER)%</argument>
81+
<argument>%env(REDIS_PASSWORD)%</argument>
82+
</call> -->
7383
</service>
7484
</services>
7585
</container>
@@ -83,6 +93,8 @@ First, define a Symfony service for the connection to the Redis server:
8393
->addMethodCall('connect', ['%env(REDIS_HOST)%', '%env(int:REDIS_PORT)%'])
8494
// uncomment the following if your Redis server requires a password:
8595
// ->addMethodCall('auth', ['%env(REDIS_PASSWORD)%'])
96+
// uncomment the following if your Redis server requires a user and a password (when user is not default):
97+
// ->addMethodCall('auth', ['%env(REDIS_USER)%', '%env(REDIS_PASSWORD)%'])
8698
;
8799
88100
Now pass this ``\Redis`` connection as an argument of the service associated to the

0 commit comments

Comments
 (0)