8000 Merge branch '3.4' into 4.1 · symfony/symfony-docs@41355ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 41355ed

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: Added documentation for validator message variables in File constraints Revert a change related to flash messages and sessions Added explanation how non-scalar or non-unique choice values are handled
2 parents 98bda5f + 5da60eb commit 41355ed

File tree

3 files changed

+119
-3
lines changed

3 files changed

+119
-3
lines changed

reference/constraints/File.rst

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ maxSizeMessage
212212

213213
The message displayed if the file is larger than the `maxSize`_ option.
214214

215+
You can use the following parameters in this message:
216+
217+
+------------------+------------------------------------------------+
218+
| Parameter | Description |
219+
+==================+================================================+
220+
| ``{{ size }}`` | File size of the given file |
221+
+------------------+------------------------------------------------+
222+
| ``{{ limit }}`` | Maximum file size allowed |
223+
+------------------+------------------------------------------------+
224+
| ``{{ suffix }}`` | Suffix for the used file size unit (see above) |
225+
+------------------+------------------------------------------------+
226+
| ``{{ file }}`` | Absolute file path |
227+
+------------------+------------------------------------------------+
228+
215229
mimeTypesMessage
216230
~~~~~~~~~~~~~~~~
217231

@@ -220,6 +234,18 @@ mimeTypesMessage
220234
The message displayed if the mime type of the file is not a valid mime type
221235
per the `mimeTypes`_ option.
222236

237+
You can use the following parameters in this message:
238+
239+
+-----------------+----------------------------------------+
240+
| Parameter | Description |
241+
+=================+========================================+
242+
| ``{{ type }}`` | The MIME type of the given file |
243+
+-----------------+----------------------------------------+
244+
| ``{{ types }}`` | The list of allowed MIME types |
245+
+-----------------+----------------------------------------+
246+
| ``{{ file }}`` | Absolute file path |
247+
+-----------------+----------------------------------------+
248+
223249
disallowEmptyMessage
224250
~~~~~~~~~~~~~~~~~~~~
225251

@@ -228,6 +254,14 @@ disallowEmptyMessage
228254
This constraint checks if the uploaded file is empty (i.e. 0 bytes). If it is,
229255
this message is displayed.
230256

257+
You can use the following parameters in this message:
258+
259+
+----------------+--------------------+
260+
| Parameter | Description |
261+
+================+====================+
262+
| ``{{ file }}`` | Absolute file path |
263+
+----------------+--------------------+
264+
231265
notFoundMessage
232266
~~~~~~~~~~~~~~~
233267

@@ -237,6 +271,14 @@ The message displayed if no file can be found at the given path. This error
237271
is only likely if the underlying value is a string path, as a ``File`` object
238272
cannot be constructed with an invalid file path.
239273

274+
You can use the following parameters in this message:
275+
276+
+----------------+--------------------+
277+
| Parameter | Description |
278+
+================+====================+
279+
| ``{{ file }}`` | Absolute file path |
280+
+----------------+--------------------+
281+
240282
notReadableMessage
241283
~~~~~~~~~~~~~~~~~~
242284

@@ -245,6 +287,14 @@ notReadableMessage
245287
The message displayed if the file exists, but the PHP ``is_readable()`` function
246288
fails when passed the path to the file.
247289

290+
You can use the following parameters in this message:
291+
292+
+----------------+--------------------+
293+
| Parameter | Description |
294+
+================+====================+
295+
| ``{{ file }}`` | Absolute file path |
296+
+----------------+--------------------+
297+
248298
uploadIniSizeErrorMessage
249299
~~~~~~~~~~~~~~~~~~~~~~~~~
250300

@@ -253,6 +303,16 @@ uploadIniSizeErrorMessage
253303
The message that is displayed if the uploaded file is larger than the ``upload_max_filesize``
254304
``php.ini`` setting.
255305

306+
You can use the following parameters in this message:
307+
308+
+------------------+------------------------------------------------+
309+
| Parameter | Description |
310+
+==================+================================================+
311+
| ``{{ limit }}`` | Maximum file size allowed |
312+
+------------------+------------------------------------------------+
313+
| ``{{ suffix }}`` | Suffix for the used file size unit (see above) |
314+
+------------------+------------------------------------------------+
315+
256316
uploadFormSizeErrorMessage
257317
~~~~~~~~~~~~~~~~~~~~~~~~~~
258318

@@ -261,14 +321,65 @@ uploadFormSizeErrorMessage
261321
The message that is displayed if the uploaded file is larger than allowed
262322
by the HTML file input field.
263323

324+
This message has no parameters.
325+
326+
uploadPartialErrorMessage
327+
~~~~~~~~~~~~~~~~~~~~~~~~~
328+
329+
**type**: ``string`` **default**: ``The file was only partially uploaded.``
330+
331+
The message that is displayed if the uploaded file is only partially uploaded.
332+
333+
This message has no parameters.
334+
335+
uploadNoFileErrorMessage
336+
~~~~~~~~~~~~~~~~~~~~~~~~
337+
338+
**type**: ``string`` **default**: ``No file was uploaded.``
339+
340+
The message that is displayed if no file was uploaded.
341+
342+
This message has no parameters.
343+
344+
uploadNoTmpDirErrorMessage
345+
~~~~~~~~~~~~~~~~~~~~~~~~~~
346+
347+
**type**: ``string`` **default**: ``No temporary folder was configured in php.ini.``
348+
349+
The message that is displayed if the php.ini setting ``upload_tmp_dir`` is
350+
missing.
351+
352+
This message has no parameters.
353+
354+
uploadCantWriteErrorMessage
355+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
356+
357+
**type**: ``string`` **default**: ``Cannot write temporary file to disk.``
358+
359+
The message that is displayed if the uploaded file can't be stored in the
360+
temporary folder.
361+
362+
This message has no parameters.
363+
364+
uploadExtensionErrorMessage
365+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
366+
367+
**type**: ``string`` **default**: ``A PHP extension caused the upload to fail.``
368+
369+
The message that is displayed if a PHP extension caused the file upload to
370+
fail.
371+
372+
This message has no parameters.
373+
264374
uploadErrorMessage
265375
~~~~~~~~~~~~~~~~~~
266376

267377
**type**: ``string`` **default**: ``The file could not be uploaded.``
268378

269379
The message that is displayed if the uploaded file could not be uploaded
270-
for some unknown reason, such as the file upload failed or it couldn't be
271-
written to disk.
380+
for some unknown reason.
381+
382+
This message has no parameters.
272383

273384
.. include:: /reference/constraints/_payload-option.rst.inc
274385

reference/forms/types/choice.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ is the item's label and the array value is the item's value::
172172
'choices' => array('In Stock' => true, 'Out of Stock' => false),
173173
));
174174

175+
If there are choice values that are not scalar or the stringified
176+
representation is not unique Symfony will use incrementing integers
177+
as values. When the form gets submitted the correct values with the
178+
correct types will be assigned to the model.
179+
175180
.. include:: /reference/forms/types/options/choice_attr.rst.inc
176181

177182
.. _reference-form-choice-label:

session/avoid_session_start.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ access the flash messages:
2929

3030
.. code-block:: html+twig
3131

32-
{% if app.request.method == 'POST' %}
32+
{% if app.request.hasPreviousSession %}
3333
{% for message in app.flashes('notice') %}
3434
<div class="flash-notice">
3535
{{ message }}

0 commit comments

Comments
 (0)
0