summaryrefslogtreecommitdiffstats
path: root/user_guide_src
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-06-22 13:45:50 +0200
committerAndrey Andreev <narf@devilix.net>2017-06-22 13:45:50 +0200
commit0c06ba0c587b5ef97718bc3b19c6dba163b7acb0 (patch)
treef653d045eeddcc31d972a3580f8b952891a70477 /user_guide_src
parenta2a49fcc322acd5ded3c0664d64bbebe982815f5 (diff)
Implement #2436 (access to FV processed data)
Diffstat (limited to 'user_guide_src')
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/form_validation.rst21
2 files changed, 21 insertions, 1 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index c1f53dac0..db2be2014 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -52,6 +52,7 @@ Release Date: Not Released
- Changed method ``set_rules()`` to throw a ``BadMethodCallException`` when its first parameter is not an array and the ``$rules`` one is unused.
- Added rule **valid_mac**, which replicates PHP's native ``filter_var()`` with ``FILTER_VALIDATE_MAC``.
- Added ability to validate entire arrays at once, if ``is_array`` is within the list of rules.
+ - Added ability to fetch processed data via a second parameter to ``run()``.
- :doc:`HTML Table Library <libraries/table>` changes include:
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 6a92cc983..fd2f3af94 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -881,6 +881,24 @@ When a rule group is named identically to a controller class/method it
will be used automatically when the ``run()`` method is invoked from that
class/method.
+Accessing validated/processed data
+==================================
+
+By default, validation will be performed directly on the ``$_POST`` array,
+and any possible modifications (like trimming whitespace, for example)
+would be written back onto it.
+However, if you want to keep the original input data intact, or have used
+``set_data()`` to pass a custom set of inputs, you would likely want to
+fetch the now-modified data. In order to do that, you can pass a variable
+as the second parameter to ``run()``::
+
+ $input = array('name' => ' White Space ');
+ $output = NULL;
+
+ $this->form_validation->set_rules('name', 'Name', 'required|trim');
+ $this->form_validation->run(NULL, $output);
+ // $output will now contain: array('name' => 'White Space');
+
.. _using-arrays-as-field-names:
***************************
@@ -1043,9 +1061,10 @@ Class Reference
- :ref:`setting-validation-rules`
- :ref:`saving-groups`
- .. php:method:: run([$group = ''])
+ .. php:method:: run([$config = NULL[, $data = NULL]])
:param string $group: The name of the validation group to run
+ :param mixed $data: Optional variable to assign validated data to
:returns: TRUE on success, FALSE if validation failed
:rtype: bool