From 312a951ed4029cf2308432b9eb65f1259345ffe5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 May 2024 10:56:06 +0900 Subject: [PATCH] docs: add descriptions --- .../source/libraries/uploaded_files.rst | 16 +++++++++++++--- user_guide_src/source/libraries/validation.rst | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index ec139b59ae64..ef1bc6b592f6 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -83,9 +83,19 @@ this code and save it to your **app/Controllers** directory: .. literalinclude:: uploaded_files/002.php -.. note:: Since the value of a file upload HTML field doesn't exist, and is stored in the ``$_FILES`` global, - only :ref:`rules-for-file-uploads` can be used to validate upload file with :doc:`validation`. - The rule ``required`` also can't be used, so use ``uploaded`` instead. +Since the value of a file upload HTML field doesn't exist, and is stored in the +``$_FILES`` global, only :ref:`rules-for-file-uploads` can be used to validate +upload file with :doc:`validation`. + +The rule ``required`` cannot be used either, so if the file is required, use +the rule ``uploaded`` instead. + +Note that an empty array (``[]``) is passed as the first argument to +``$this->validateData()``. It is because the file validation rules get the data +for the uploaded file directly from the Request object. + +If the form has fields other than file upload, pass the field data as the first +argument. The Routes ========== diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index 8fa91533c16b..3b16ad588d87 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -885,6 +885,8 @@ Available Rules .. literalinclude:: validation/038.php :lines: 2- +.. _rules-for-general-use: + Rules for General Use ===================== @@ -1057,6 +1059,8 @@ parameter of all file upload related rules:: 'avatar' => 'uploaded[avatar]|max_size[avatar,1024]', ]); +See also :ref:`file-upload-form-tutorial`. + ======================= ========== ============================================= =================================================== Rule Parameter Description Example ======================= ========== ============================================= ===================================================