From ca51e1a5695bfdf76d8db599ee6c7ba16c328bbc Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Sun, 21 Jul 2013 13:35:02 -0700 Subject: removing php: directive prefix from docs source as it is not necessary --- .../source/libraries/form_validation.rst | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'user_guide_src/source/libraries/form_validation.rst') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 8b35fdc75..5dffb1cd1 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -477,8 +477,8 @@ following method:: Where rule corresponds to the name of a particular rule, and Error Message is the text you would like displayed. -If you'd like to include a field's "human" name, or the optional -parameter some rules allow for (such as max_length), you can add the +If you'd like to include a field's "human" name, or the optional +parameter some rules allow for (such as max_length), you can add the **{field}** and **{param}** tags to your message, respectively:: $this->form_validation->set_message('min_length', '{field} must have at least {param} characters.'); @@ -860,14 +860,14 @@ use: ========================= ========== ============================================================================================= ======================= Rule Parameter Description Example ========================= ========== ============================================================================================= ======================= -**required** No Returns FALSE if the form element is empty. -**matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] -**differs** Yes Returns FALSE if the form element does not differ from the one in the parameter. differs[form_item] -**is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] - parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be +**required** No Returns FALSE if the form element is empty. +**matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] +**differs** Yes Returns FALSE if the form element does not differ from the one in the parameter. differs[form_item] +**is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] + parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be enabled in order to work. -**max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] -**exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] +**max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] +**exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] **greater_than** Yes Returns FALSE if the form element is less than or equal to the parameter value or not greater_than[8] numeric. **greater_than_equal_to** Yes Returns FALSE if the form element is less than the parameter value, greater_than_equal_to[8] @@ -876,15 +876,15 @@ Rule Parameter Description not numeric. **less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8] or not numeric. -**alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. +**alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. **alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. **alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters - or spaces. Should be used after trim to avoid spaces at the beginning or end. -**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, - underscores or dashes. -**numeric** No Returns FALSE if the form element contains anything other than numeric characters. -**integer** No Returns FALSE if the form element contains anything other than an integer. -**decimal** No Returns FALSE if the form element contains anything other than a decimal number. + or spaces. Should be used after trim to avoid spaces at the beginning or end. +**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, + underscores or dashes. +**numeric** No Returns FALSE if the form element contains anything other than numeric characters. +**integer** No Returns FALSE if the form element contains anything other than an integer. +**decimal** No Returns FALSE if the form element contains anything other than a decimal number. **is_natural** No Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc. **is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural @@ -933,14 +933,14 @@ Name Parameter Description Class Reference *************** -.. php:class:: Form_validation +.. class:: Form_validation The following methods are intended for use in your controller. $this->form_validation->set_rules() =================================== - .. php:method:: set_rules ($field, $label = '', $rules = '') + .. method:: set_rules ($field, $label = '', $rules = '') :param string $field: The field name :param string $label: The field label @@ -955,8 +955,8 @@ $this->form_validation->set_rules() $this->form_validation->run() ============================= - - .. php:method:: run ($group = '') + + .. method:: run ($group = '') :param string $group: The name of the validation group to run :rtype: Boolean @@ -967,8 +967,8 @@ $this->form_validation->run() $this->form_validation->set_message() ===================================== - - .. php:method:: set_message ($lang, $val = '') + + .. method:: set_message ($lang, $val = '') :param string $lang: The rule the message is for :param string $val: The message @@ -978,8 +978,8 @@ $this->form_validation->set_message() $this->form_validation->set_data() ================================== - - .. php:method:: set_data ($data = '') + + .. method:: set_data ($data = '') :param array $data: The data to validate @@ -989,15 +989,15 @@ $this->form_validation->set_data() $this->form_validation->reset_validation() ========================================== - .. php:method:: reset_validation () + .. method:: reset_validation () Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array. $this->form_validation->error_array() ===================================== - - .. php:method:: error_array () + + .. method:: error_array () :rtype: Array @@ -1031,7 +1031,7 @@ Shows all error messages as a string: Example:: -The error delimiters can be optionally specified. See the +The error delimiters can be optionally specified. See the :ref:`changing-delimiters` section above. set_value() -- cgit v1.2.3-24-g4f1b From ecc7993a910bf8202ba022487288921a9c50e336 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 6 Jan 2014 11:22:31 +0200 Subject: [ci skip] Update the Form_validation library docs --- .../source/libraries/form_validation.rst | 168 ++++++++------------- 1 file changed, 61 insertions(+), 107 deletions(-) (limited to 'user_guide_src/source/libraries/form_validation.rst') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 5dffb1cd1..35f745fb7 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -340,10 +340,10 @@ commonly is:: set_value('field name') Open your myform.php view file and update the **value** in each field -using the ``set_value()`` function: +using the :func:`set_value()` function: -**Don't forget to include each field name in the ``set_value()`` -functions!** +**Don't forget to include each field name in the :func:`set_value()` +function calls!** :: @@ -380,11 +380,11 @@ Now reload your page and submit the form so that it triggers an error. Your form fields should now be re-populated .. note:: The :ref:`class-reference` section below - contains functions that permit you to re-populate menus, radio buttons, and checkboxes. -**Important Note:** If you use an array as the name of a form field, you -must supply it as an array to the function. Example:: +.. important:: If you use an array as the name of a form field, you + must supply it as an array to the function. Example:: @@ -559,7 +559,7 @@ Showing Errors Individually =========================== If you prefer to show an error message next to each form field, rather -than as a list, you can use the ``form_error()`` function. +than as a list, you can use the :func:`form_error()` function. Try it! Change your form so that it looks like this:: @@ -933,154 +933,108 @@ Name Parameter Description Class Reference *************** -.. class:: Form_validation - -The following methods are intended for use in your controller. +.. class:: CI_Form_validation -$this->form_validation->set_rules() -=================================== - - .. method:: set_rules ($field, $label = '', $rules = '') + .. method:: set_rules($field[, $label = ''[, $rules = '']]) :param string $field: The field name :param string $label: The field label :param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules. - :rtype: Object + :returns: object Permits you to set validation rules, as described in the tutorial sections above: - - :ref:`setting-validation-rules` - - :ref:`saving-groups` + - :ref:`setting-validation-rules` + - :ref:`saving-groups` -$this->form_validation->run() -============================= - - .. method:: run ($group = '') + .. method:: run([$group = '']) :param string $group: The name of the validation group to run - :rtype: Boolean + :returns: bool Runs the validation routines. Returns boolean TRUE on success and FALSE on failure. You can optionally pass the name of the validation group via the method, as described in: :ref:`saving-groups` -$this->form_validation->set_message() -===================================== - - .. method:: set_message ($lang, $val = '') + .. method:: set_message($lang[, $val = '']) :param string $lang: The rule the message is for :param string $val: The message - :rtype: Object + :returns: object Permits you to set custom error messages. See :ref:`setting-error-messages` -$this->form_validation->set_data() -================================== + .. method:: set_error_delimiters([$prefix = '

'[, $suffix = '

']]) + + :param string $prefix: Error message prefix + :param string $suffix: Error message suffix + :returns: object + + Sets the default prefix and suffix for error messages. - .. method:: set_data ($data = '') + .. method:: set_data($data) :param array $data: The data to validate + :returns: void Permits you to set an array for validation, instead of using the default - $_POST array. + ``$_POST`` array. -$this->form_validation->reset_validation() -========================================== + .. method:: reset_validation() - .. method:: reset_validation () + :returns: void Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array. -$this->form_validation->error_array() -===================================== + .. method:: error_array() - .. method:: error_array () - - :rtype: Array + :returns: array Returns the error messages as an array. -.. _helper-functions: - -**************** -Helper Reference -**************** - -The following helper functions are available for use in the view files -containing your forms. Note that these are procedural functions, so they -**do not** require you to prepend them with $this->form_validation. - -form_error() -============ - -Shows an individual error message associated with the field name -supplied to the function. Example:: + .. method:: error_string([$prefix = ''[, $suffix = '']]) - - -The error delimiters can be optionally specified. See the -:ref:`changing-delimiters` section above. - -validation_errors() -=================== - -Shows all error messages as a string: Example:: - - - -The error delimiters can be optionally specified. See the -:ref:`changing-delimiters` section above. - -set_value() -=========== + :param string $prefix: Error message prefix + :param string $suffix: Error message suffix + :returns: string -Permits you to set the value of an input form or textarea. You must -supply the field name via the first parameter of the function. The -second (optional) parameter allows you to set a default value for the -form. Example:: + Returns all error messages (as returned from error_array()) formatted as a + string and separated by a newline character. - + .. method:: error($field[, $prefix = ''[, $suffix = '']]) -The above form will show "0" when loaded for the first time. + :param string $field: Field name + :param string $prefix: Optional prefix + :param string $suffix: Optional suffix + :returns: string -set_select() -============ + Returns the error message for a specific field, optionally adding a + prefix and/or suffix to it (usually HTML tags). -If you use a - - - - + Checks to see if there is a rule set for the specified field. -set_checkbox() -============== - -Permits you to display a checkbox in the state it was submitted. The -first parameter must contain the name of the checkbox, the second -parameter must contain its value, and the third (optional) parameter -lets you set an item as the default (use boolean TRUE/FALSE). Example:: - - /> - /> +.. _helper-functions: -set_radio() -=========== +**************** +Helper Reference +**************** -Permits you to display radio buttons in the state they were submitted. -This function is identical to the **set_checkbox()** function above. +Please refer to the :doc:`Form Helper <../helpers/form_helper>` manual for +the following functions: -:: +- :func:`form_error()` +- :func:`validation_errors()` +- :func:`set_value()` +- :func:`set_select()` +- :func:`set_checkbox()` +- :func:`set_radio()` - /> - /> +Note that these are procedural functions, so they **do not** require you +to prepend them with ``$this->form_validation``. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 28c2c975b118016d07212ed8e7c22ff280309f82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 04:27:48 +0200 Subject: [ci skip] Add return types to library docs --- .../source/libraries/form_validation.rst | 58 ++++++++++++---------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'user_guide_src/source/libraries/form_validation.rst') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 42422f9d7..ae66cefb3 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -958,10 +958,11 @@ Class Reference .. method:: set_rules($field[, $label = ''[, $rules = '']]) - :param string $field: The field name - :param string $label: The field label - :param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules. - :returns: object + :param string $field: Field name + :param string $label: Field label + :param mixed $rules: Validation rules, as a string list separated by a pipe "|", or as an array or rules + :returns: CI_Form_validation instance (method chaining) + :rtype: CI_Form_validation Permits you to set validation rules, as described in the tutorial sections above: @@ -971,8 +972,9 @@ Class Reference .. method:: run([$group = '']) - :param string $group: The name of the validation group to run - :returns: bool + :param string $group: The name of the validation group to run + :returns: TRUE on success, FALSE if validation failed + :rtype: bool Runs the validation routines. Returns boolean TRUE on success and FALSE on failure. You can optionally pass the name of the validation group via @@ -980,64 +982,70 @@ Class Reference .. method:: set_message($lang[, $val = '']) - :param string $lang: The rule the message is for - :param string $val: The message - :returns: object + :param string $lang: The rule the message is for + :param string $val: The message + :returns: CI_Form_validation instance (method chaining) + :rtype: CI_Form_validation Permits you to set custom error messages. See :ref:`setting-error-messages` .. method:: set_error_delimiters([$prefix = '

'[, $suffix = '

']]) - :param string $prefix: Error message prefix - :param string $suffix: Error message suffix - :returns: object + :param string $prefix: Error message prefix + :param string $suffix: Error message suffix + :returns: CI_Form_validation instance (method chaining) + :rtype: CI_Form_validation Sets the default prefix and suffix for error messages. .. method:: set_data($data) - :param array $data: The data to validate - :returns: void + :param array $data: Array of data validate + :rtype: void Permits you to set an array for validation, instead of using the default ``$_POST`` array. .. method:: reset_validation() - :returns: void + :rtype: void Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array. .. method:: error_array() - :returns: array + :returns: Array of error messages + :rtype: array Returns the error messages as an array. .. method:: error_string([$prefix = ''[, $suffix = '']]) - :param string $prefix: Error message prefix - :param string $suffix: Error message suffix - :returns: string + :param string $prefix: Error message prefix + :param string $suffix: Error message suffix + :returns: Error messages as a string + :rtype: string Returns all error messages (as returned from error_array()) formatted as a string and separated by a newline character. .. method:: error($field[, $prefix = ''[, $suffix = '']]) - :param string $field: Field name - :param string $prefix: Optional prefix - :param string $suffix: Optional suffix - :returns: string + :param string $field: Field name + :param string $prefix: Optional prefix + :param string $suffix: Optional suffix + :returns: Error message string + :rtype: string Returns the error message for a specific field, optionally adding a prefix and/or suffix to it (usually HTML tags). .. method:: has_rule($field) - :param string $field: Field name - :returns: bool + :param string $field: Field name + :returns: TRUE if the field has rules set, FALSE if not + :rtype: bool Checks to see if there is a rule set for the specified field. -- cgit v1.2.3-24-g4f1b From a89c1dabd11e8628106b1629f76ec9fc65c20085 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 19:03:35 +0200 Subject: Method chaining support for FV set_data(), reset_validation() --- user_guide_src/source/libraries/form_validation.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries/form_validation.rst') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index ae66cefb3..988d6fa25 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -1001,14 +1001,16 @@ Class Reference .. method:: set_data($data) :param array $data: Array of data validate - :rtype: void + :returns: CI_Form_validation instance (method chaining) + :rtype: CI_Form_validation Permits you to set an array for validation, instead of using the default ``$_POST`` array. .. method:: reset_validation() - :rtype: void + :returns: CI_Form_validation instance (method chaining) + :rtype: CI_Form_validation Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array. -- cgit v1.2.3-24-g4f1b