Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix issue #539

Form validation language line keys were not prefixed. They are
now prefixed with 'form_validation_' in order to avoid collisions.
The old keys will still work if a prefixed match is not found, but
are DEPRECATED and will be removed in the next major version.

Also added upgrade notes and changelog entries for the new error
message format from PR #961.
  • Loading branch information...
commit d4eec9f3638cc31dc8965f929b74a2b3b201b8b7 1 parent 749f250
Andrey Andreev narfbg authored
52 system/language/english/form_validation_lang.php
@@ -26,32 +26,32 @@
26 26 */
27 27 defined('BASEPATH') OR exit('No direct script access allowed');
28 28
29   -$lang['required'] = 'The {field} field is required.';
30   -$lang['isset'] = 'The {field} field must have a value.';
31   -$lang['valid_email'] = 'The {field} field must contain a valid email address.';
32   -$lang['valid_emails'] = 'The {field} field must contain all valid email addresses.';
33   -$lang['valid_url'] = 'The {field} field must contain a valid URL.';
34   -$lang['valid_ip'] = 'The {field} field must contain a valid IP.';
35   -$lang['min_length'] = 'The {field} field must be at least {param} characters in length.';
36   -$lang['max_length'] = 'The {field} field cannot exceed {param} characters in length.';
37   -$lang['exact_length'] = 'The {field} field must be exactly {param} characters in length.';
38   -$lang['alpha'] = 'The {field} field may only contain alphabetical characters.';
39   -$lang['alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
40   -$lang['alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
41   -$lang['numeric'] = 'The {field} field must contain only numbers.';
42   -$lang['is_numeric'] = 'The {field} field must contain only numeric characters.';
43   -$lang['integer'] = 'The {field} field must contain an integer.';
44   -$lang['regex_match'] = 'The {field} field is not in the correct format.';
45   -$lang['matches'] = 'The {field} field does not match the {param} field.';
46   -$lang['differs'] = 'The {field} field must differ from the {param} field.';
47   -$lang['is_unique'] = 'The {field} field must contain a unique value.';
48   -$lang['is_natural'] = 'The {field} field must only contain digits.';
49   -$lang['is_natural_no_zero'] = 'The {field} field must only contain digits and must be greater than zero.';
50   -$lang['decimal'] = 'The {field} field must contain a decimal number.';
51   -$lang['less_than'] = 'The {field} field must contain a number less than {param}.';
52   -$lang['less_than_equal_to'] = 'The {field} field must contain a number less than or equal to {param}.';
53   -$lang['greater_than'] = 'The {field} field must contain a number greater than {param}.';
54   -$lang['greater_than_equal_to'] = 'The {field} field must contain a number greater than or equal to {param}.';
  29 +$lang['form_validation_required'] = 'The {field} field is required.';
  30 +$lang['form_validation_isset'] = 'The {field} field must have a value.';
  31 +$lang['form_validation_valid_email'] = 'The {field} field must contain a valid email address.';
  32 +$lang['form_validation_valid_emails'] = 'The {field} field must contain all valid email addresses.';
  33 +$lang['form_validation_valid_url'] = 'The {field} field must contain a valid URL.';
  34 +$lang['form_validation_valid_ip'] = 'The {field} field must contain a valid IP.';
  35 +$lang['form_validation_min_length'] = 'The {field} field must be at least {param} characters in length.';
  36 +$lang['form_validation_max_length'] = 'The {field} field cannot exceed {param} characters in length.';
  37 +$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.';
  38 +$lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.';
  39 +$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
  40 +$lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
  41 +$lang['form_validation_numeric'] = 'The {field} field must contain only numbers.';
  42 +$lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.';
  43 +$lang['form_validation_integer'] = 'The {field} field must contain an integer.';
  44 +$lang['form_validation_regex_match'] = 'The {field} field is not in the correct format.';
  45 +$lang['form_validation_matches'] = 'The {field} field does not match the {param} field.';
  46 +$lang['form_validation_differs'] = 'The {field} field must differ from the {param} field.';
  47 +$lang['form_validation_is_unique'] = 'The {field} field must contain a unique value.';
  48 +$lang['form_validation_is_natural'] = 'The {field} field must only contain digits.';
  49 +$lang['form_validation_is_natural_no_zero'] = 'The {field} field must only contain digits and must be greater than zero.';
  50 +$lang['form_validation_decimal'] = 'The {field} field must contain a decimal number.';
  51 +$lang['form_validation_less_than'] = 'The {field} field must contain a number less than {param}.';
  52 +$lang['form_validation_less_than_equal_to'] = 'The {field} field must contain a number less than or equal to {param}.';
  53 +$lang['form_validation_greater_than'] = 'The {field} field must contain a number greater than {param}.';
  54 +$lang['form_validation_greater_than_equal_to'] = 'The {field} field must contain a number greater than or equal to {param}.';
55 55
56 56 /* End of file form_validation_lang.php */
57 57 /* Location: ./system/language/english/form_validation_lang.php */
14 system/libraries/Form_validation.php
@@ -609,7 +609,9 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
609 609 {
610 610 $line = $this->_error_messages[$type];
611 611 }
612   - elseif (FALSE === ($line = $this->CI->lang->line($type)))
  612 + elseif (FALSE === ($line = $this->CI->lang->line('form_validation_'.$type))
  613 + // DEPRECATED support for non-prefixed keys
  614 + && FALSE === ($line = $this->CI->lang->line($type, FALSE)))
613 615 {
614 616 $line = 'The field was not set';
615 617 }
@@ -749,7 +751,9 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
749 751 {
750 752 if ( ! isset($this->_error_messages[$rule]))
751 753 {
752   - if (FALSE === ($line = $this->CI->lang->line($rule)))
  754 + if (FALSE === ($line = $this->CI->lang->line('form_validation_'.$rule))
  755 + // DEPRECATED support for non-prefixed keys
  756 + && FALSE === ($line = $this->CI->lang->line($rule, FALSE)))
753 757 {
754 758 $line = 'Unable to access an error message corresponding to your field name.';
755 759 }
@@ -797,7 +801,9 @@ protected function _translate_fieldname($fieldname)
797 801 if (sscanf($fieldname, 'lang:%s', $line) === 1)
798 802 {
799 803 // Were we able to translate the field name? If not we use $line
800   - if (FALSE === ($fieldname = $this->CI->lang->line($line)))
  804 + if (FALSE === ($fieldname = $this->CI->lang->line('form_validation_'.$line))
  805 + // DEPRECATED support for non-prefixed keys
  806 + && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE)))
801 807 {
802 808 return $line;
803 809 }
@@ -807,7 +813,7 @@ protected function _translate_fieldname($fieldname)
807 813 }
808 814
809 815 // --------------------------------------------------------------------
810   -
  816 +
811 817 /**
812 818 * Build an error message using the field and param.
813 819 *
8 user_guide_src/source/changelog.rst
Source Rendered
@@ -73,7 +73,7 @@ Release Date: Not Released
73 73 - Added JS window name support to the :php:func:`anchor_popup()` function.
74 74 - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`.
75 75 - Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used).
76   - - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs, such as `redirect('//ellislab.com/codeigniter')`.
  76 + - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*).
77 77 - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
78 78 - :doc:`Inflector Helper <helpers/inflector_helper>` changes include:
79 79 - Changed :php:func:`humanize()` to allow passing an input separator as its second parameter.
@@ -225,13 +225,15 @@ Release Date: Not Released
225 225 - Added method ``set_data()`` to set an alternative data array to be validated instead of the default ``$_POST``.
226 226 - Added method ``reset_validation()`` which resets internal validation variables in case of multiple validation routines.
227 227 - Added support for setting error delimiters in the config file via ``$config['error_prefix']`` and ``$config['error_suffix']``.
228   - - ``_execute()`` now considers input data to be invalid if a specified rule is not found.
  228 + - Internal method ``_execute()`` now considers input data to be invalid if a specified rule is not found.
229 229 - Removed method ``is_numeric()`` as it exists as a native PHP function and ``_execute()`` will find and use that (the **is_numeric** rule itself is deprecated since 1.6.1).
230 230 - Native PHP functions used as rules can now accept an additional parameter, other than the data itself.
231   - - Updated ``set_rules()`` to accept an array of rules as well as a string.
  231 + - Updated method ``set_rules()`` to accept an array of rules as well as a string.
232 232 - Fields that have empty rules set no longer run through validation (and therefore are not considered erroneous).
233 233 - Added rule **differs* to check if the value of a field differs from the value of another field.
234 234 - Added rule **valid_url**.
  235 + - Added support for named parameters in error messages.
  236 + - :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**.
235 237 - Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
236 238 - :doc:`Caching Library <libraries/caching>` changes include:
237 239 - Added Wincache driver.
38 user_guide_src/source/installation/upgrade_300.rst
Source Rendered
@@ -138,7 +138,7 @@ If your application relies on IF EXISTS, you'll have to change its usage.
138 138 Step 11: Change usage of Email library with multiple emails
139 139 ***********************************************************
140 140
141   -The :doc:`Email library <../libraries/email>` will automatically clear the
  141 +The :doc:`Email Library <../libraries/email>` will automatically clear the
142 142 set parameters after successfully sending emails. To override this behaviour,
143 143 pass FALSE as the first parameter in the ``send()`` method:
144 144
@@ -149,13 +149,43 @@ pass FALSE as the first parameter in the ``send()`` method:
149 149 // Parameters won't be cleared
150 150 }
151 151
  152 +***************************************************
  153 +Step 12: Update your Form_validation language lines
  154 +***************************************************
  155 +
  156 +Two improvements have been made to the :doc:`Form Validation Library
  157 +<../libraries/form_validation>`'s :doc:`language <../libraries/language>`
  158 +files and error messages format:
  159 +
  160 + - :doc:`Language Library <../libraries/language>` line keys now must be
  161 + prefixed with **form_validation_** in order to avoid collisions::
  162 +
  163 + // Old
  164 + $lang['rule'] = ...
  165 +
  166 + // New
  167 + $lang['form_validation_rule'] = ...
  168 +
  169 + - The error messages format has been changed to use named parameters, to
  170 + allow more flexibility than what `sprintf()` offers::
  171 +
  172 + // Old
  173 + 'The %s field does not match the %s field.'
  174 +
  175 + // New
  176 + 'The {field} field does not match the {param} field.'
  177 +
  178 +.. note:: The old formatting still works, but the non-prefixed line keys
  179 + are DEPRECATED and scheduled for removal in CodeIgniter 3.1+.
  180 + Therefore you're encouraged to update its usage sooner rather than
  181 + later.
152 182
153 183 ****************************************************************
154   -Step 12: Remove usage of (previously) deprecated functionalities
  184 +Step 13: Remove usage of (previously) deprecated functionalities
155 185 ****************************************************************
156 186
157   -In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
158   -that have been removed in CodeIgniter 3.0.0:
  187 +In addition to the ``$autoload['core']`` configuration setting, there's a
  188 +number of other functionalities that have been removed in CodeIgniter 3.0.0:
159 189
160 190 The SHA1 library
161 191 ================
152 user_guide_src/source/libraries/form_validation.rst
Source Rendered
@@ -53,7 +53,7 @@ In order to implement form validation you'll need three things:
53 53 #. A :doc:`View <../general/views>` file containing a form.
54 54 #. A View file containing a "success" message to be displayed upon
55 55 successful submission.
56   -#. A :doc:`controller <../general/controllers>` function to receive and
  56 +#. A :doc:`controller <../general/controllers>` method to receive and
57 57 process the submitted data.
58 58
59 59 Let's create those three things, using a member sign-up form as the
@@ -151,7 +151,7 @@ If you submit the form you should simply see the form reload. That's
151 151 because you haven't set up any validation rules yet.
152 152
153 153 **Since you haven't told the Form Validation class to validate anything
154   -yet, it returns FALSE (boolean false) by default. The run() function
  154 +yet, it returns FALSE (boolean false) by default. ``The run()`` method
155 155 only returns TRUE if it has successfully applied your rules without any
156 156 of them failing.**
157 157
@@ -175,7 +175,7 @@ The form (myform.php) is a standard web form with a couple exceptions:
175 175 This function will return any error messages sent back by the
176 176 validator. If there are no messages it returns an empty string.
177 177
178   -The controller (form.php) has one function: index(). This function
  178 +The controller (form.php) has one method: ``index()``. This method
179 179 initializes the validation class and loads the form helper and URL
180 180 helper used by your view files. It also runs the validation routine.
181 181 Based on whether the validation was successful it either presents the
@@ -189,11 +189,11 @@ Setting Validation Rules
189 189 CodeIgniter lets you set as many validation rules as you need for a
190 190 given field, cascading them in order, and it even lets you prep and
191 191 pre-process the field data at the same time. To set validation rules you
192   -will use the set_rules() function::
  192 +will use the ``set_rules()`` method::
193 193
194 194 $this->form_validation->set_rules();
195 195
196   -The above function takes **three** parameters as input:
  196 +The above method takes **three** parameters as input:
197 197
198 198 #. The field name - the exact name you've given the form field.
199 199 #. A "human" name for this field, which will be inserted into the error
@@ -201,11 +201,11 @@ The above function takes **three** parameters as input:
201 201 a human name of "Username".
202 202 #. The validation rules for this form field.
203 203
204   -.. note:: If you would like the field
205   - name to be stored in a language file, please see :ref:`translating-field-names`.
  204 +.. note:: If you would like the field name to be stored in a language
  205 + file, please see :ref:`translating-field-names`.
206 206
207 207 Here is an example. In your controller (form.php), add this code just
208   -below the validation initialization function::
  208 +below the validation initialization method::
209 209
210 210 $this->form_validation->set_rules('username', 'Username', 'required');
211 211 $this->form_validation->set_rules('password', 'Password', 'required');
@@ -250,7 +250,7 @@ see your success page.
250 250 Setting Rules Using an Array
251 251 ============================
252 252
253   -Before moving on it should be noted that the rule setting function can
  253 +Before moving on it should be noted that the rule setting method can
254 254 be passed an array if you prefer to set all your rules in one action. If
255 255 you use this approach, you must name your array keys as indicated::
256 256
@@ -283,7 +283,7 @@ Cascading Rules
283 283 ===============
284 284
285 285 CodeIgniter lets you pipe multiple rules together. Let's try it. Change
286   -your rules in the third parameter of rule setting function, like this::
  286 +your rules in the third parameter of rule setting method, like this::
287 287
288 288 $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]');
289 289 $this->form_validation->set_rules('password', 'Password', 'required');
@@ -301,14 +301,15 @@ Give it a try! Submit your form without the proper data and you'll see
301 301 new error messages that correspond to your new rules. There are numerous
302 302 rules available which you can read about in the validation reference.
303 303
304   -.. note:: You can also pass an array of rules to set_rules(), instead of a string. Example::
  304 +.. note:: You can also pass an array of rules to ``set_rules()``,
  305 + instead of a string. Example::
305 306
306 307 $this->form_validation->set_rules('username', 'Username', array('required', 'min_length[5]'));
307 308
308 309 Prepping Data
309 310 =============
310 311
311   -In addition to the validation functions like the ones we used above, you
  312 +In addition to the validation method like the ones we used above, you
312 313 can also prep your data in various ways. For example, you can set up
313 314 rules like this::
314 315
@@ -318,15 +319,15 @@ rules like this::
318 319 $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
319 320
320 321 In the above example, we are "trimming" the fields, converting the
321   -password to MD5, and running the username through the "xss_clean"
322   -function, which removes malicious data.
  322 +password to MD5, and running the username through the `xss_clean()`
  323 +method, which removes malicious data.
323 324
324 325 **Any native PHP function that accepts one parameter can be used as a
325 326 rule, like htmlspecialchars, trim, md5, etc.**
326 327
327 328 .. note:: You will generally want to use the prepping functions
328   - **after** the validation rules so if there is an error, the original
329   - data will be shown in the form.
  329 + **after** the validation rules so if there is an error, the
  330 + original data will be shown in the form.
330 331
331 332 Re-populating the form
332 333 ======================
@@ -339,9 +340,9 @@ commonly is::
339 340 set_value('field name')
340 341
341 342 Open your myform.php view file and update the **value** in each field
342   -using the set_value() function:
  343 +using the ``set_value()`` function:
343 344
344   -**Don't forget to include each field name in the set_value()
  345 +**Don't forget to include each field name in the ``set_value()``
345 346 functions!**
346 347
347 348 ::
@@ -378,9 +379,9 @@ functions!**
378 379 Now reload your page and submit the form so that it triggers an error.
379 380 Your form fields should now be re-populated
380 381
381   -.. note:: The :ref:`function-reference` section below
382   - contains functions that permit you to re-populate <select> menus, radio
383   - buttons, and checkboxes.
  382 +.. note:: The :ref:`class-reference` section below
  383 + contains functions that permit you to re-populate <select> menus,
  384 + radio buttons, and checkboxes.
384 385
385 386 **Important Note:** If you use an array as the name of a form field, you
386 387 must supply it as an array to the function. Example::
@@ -389,20 +390,20 @@ must supply it as an array to the function. Example::
389 390
390 391 For more info please see the :ref:`using-arrays-as-field-names` section below.
391 392
392   -Callbacks: Your own Validation Functions
393   -========================================
  393 +Callbacks: Your own Validation Methods
  394 +======================================
394 395
395 396 The validation system supports callbacks to your own validation
396   -functions. This permits you to extend the validation class to meet your
  397 +methods. This permits you to extend the validation class to meet your
397 398 needs. For example, if you need to run a database query to see if the
398   -user is choosing a unique username, you can create a callback function
  399 +user is choosing a unique username, you can create a callback method
399 400 that does that. Let's create an example of this.
400 401
401 402 In your controller, change the "username" rule to this::
402 403
403 404 $this->form_validation->set_rules('username', 'Username', 'callback_username_check');
404 405
405   -Then add a new function called username_check to your controller.
  406 +Then add a new method called ``username_check()`` to your controller.
406 407 Here's how your controller should now look::
407 408
408 409 <?php
@@ -430,7 +431,7 @@ Here's how your controller should now look::
430 431 }
431 432 }
432 433
433   - public function username_check($str)
  434 + protected function username_check($str)
434 435 {
435 436 if ($str == 'test')
436 437 {
@@ -446,14 +447,14 @@ Here's how your controller should now look::
446 447 }
447 448
448 449 Reload your form and submit it with the word "test" as the username. You
449   -can see that the form field data was passed to your callback function
  450 +can see that the form field data was passed to your callback method
450 451 for you to process.
451 452
452   -To invoke a callback just put the function name in a rule, with
  453 +To invoke a callback just put the method name in a rule, with
453 454 "callback\_" as the rule **prefix**. If you need to receive an extra
454   -parameter in your callback function, just add it normally after the
455   -function name between square brackets, as in: "callback_foo**[bar]**",
456   -then it will be passed as the second argument of your callback function.
  455 +parameter in your callback method, just add it normally after the
  456 +method name between square brackets, as in: "callback_foo**[bar]**",
  457 +then it will be passed as the second argument of your callback method.
457 458
458 459 .. note:: You can also process the form data that is passed to your
459 460 callback and return it. If your callback returns anything other than a
@@ -466,10 +467,10 @@ Setting Error Messages
466 467 ======================
467 468
468 469 All of the native error messages are located in the following language
469   -file: system/language/english/form_validation_lang.php
  470 +file: **system/language/english/form_validation_lang.php**
470 471
471 472 To set your own custom message you can either edit that file, or use the
472   -following function::
  473 +following method::
473 474
474 475 $this->form_validation->set_message('rule', 'Error Message');
475 476
@@ -485,12 +486,12 @@ parameter some rules allow for (such as max_length), you can add the
485 486 On a field with the human name Username and a rule of min_length[5], an
486 487 error would display: "Username must have at least 5 characters."
487 488
488   -.. note:: The old method of using **%s** in your error messages will
489   -still work, however it will override the tags above. You should use
490   -one or the other.
  489 +.. note:: The old `sprintf()` method of using **%s** in your error messages
  490 + will still work, however it will override the tags above. You should
  491 + use one or the other.
491 492
492 493 In the callback rule example above, the error message was set by passing
493   -the name of the function (without the "callback_" prefix)::
  494 +the name of the method (without the "callback_" prefix)::
494 495
495 496 $this->form_validation->set_message('username_check')
496 497
@@ -500,10 +501,10 @@ Translating Field Names
500 501 =======================
501 502
502 503 If you would like to store the "human" name you passed to the
503   -set_rules() function in a language file, and therefore make the name
  504 +``set_rules()`` method in a language file, and therefore make the name
504 505 able to be translated, here's how:
505 506
506   -First, prefix your "human" name with lang:, as in this example::
  507 +First, prefix your "human" name with **lang:**, as in this example::
507 508
508 509 $this->form_validation->set_rules('first_name', 'lang:first_name', 'required');
509 510
@@ -531,7 +532,7 @@ each error message shown. You can either change these delimiters
531 532 globally, individually, or change the defaults in a config file.
532 533
533 534 #. **Changing delimiters Globally**
534   - To globally change the error delimiters, in your controller function,
  535 + To globally change the error delimiters, in your controller method,
535 536 just after loading the Form Validation class, add this::
536 537
537 538 $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
@@ -558,7 +559,7 @@ Showing Errors Individually
558 559 ===========================
559 560
560 561 If you prefer to show an error message next to each form field, rather
561   -than as a list, you can use the form_error() function.
  562 +than as a list, you can use the ``form_error()`` function.
562 563
563 564 Try it! Change your form so that it looks like this::
564 565
@@ -607,10 +608,11 @@ In this case, you can specify the array to be validated::
607 608 Creating validation rules, running the validation, and retrieving error messages works the
608 609 same whether you are validating ``$_POST`` data or an array.
609 610
610   -**Important Note:** If you want to validate more than one array during a single execution, then you should
611   -call the reset_validation() function before setting up rules and validating the new array.
  611 +.. important:: If you want to validate more than one array during a single
  612 + execution, then you should call the ``reset_validation()`` method
  613 + before setting up rules and validating the new array.
612 614
613   -For more info please see the :ref:`function-reference` section below.
  615 +For more info please see the :ref:`class-reference` section below.
614 616
615 617 .. _saving-groups:
616 618
@@ -621,7 +623,7 @@ Saving Sets of Validation Rules to a Config File
621 623 A nice feature of the Form Validation class is that it permits you to
622 624 store all your validation rules for your entire application in a config
623 625 file. You can organize these rules into "groups". These groups can
624   -either be loaded automatically when a matching controller/function is
  626 +either be loaded automatically when a matching controller/method is
625 627 called, or you can manually call each set as needed.
626 628
627 629 How to save your rules
@@ -730,8 +732,8 @@ method. For example, to call the signup rule you will do this::
730 732 $this->load->view('formsuccess');
731 733 }
732 734
733   -Associating a Controller Function with a Rule Group
734   -===================================================
  735 +Associating a Controller Method with a Rule Group
  736 +=================================================
735 737
736 738 An alternate (and more automatic) method of calling a rule group is to
737 739 name it according to the controller class/method you intend to use it
@@ -742,7 +744,7 @@ method named signup. Here's what your class might look like::
742 744
743 745 class Member extends CI_Controller {
744 746
745   - function signup()
  747 + public function signup()
746 748 {
747 749 $this->load->library('form_validation');
748 750
@@ -785,9 +787,9 @@ member/signup::
785 787 )
786 788 );
787 789
788   -When a rule group is named identically to a controller class/function it
789   -will be used automatically when the run() function is invoked from that
790   -class/function.
  790 +When a rule group is named identically to a controller class/method it
  791 +will be used automatically when the ``run()`` method is invoked from that
  792 +class/method.
791 793
792 794 .. _using-arrays-as-field-names:
793 795
@@ -893,7 +895,7 @@ Rule Parameter Description
893 895 **valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters.
894 896 ========================= ========== ============================================================================================= =======================
895 897
896   -.. note:: These rules can also be called as discrete functions. For
  898 +.. note:: These rules can also be called as discrete methods. For
897 899 example::
898 900
899 901 $this->form_validation->required($string);
@@ -906,13 +908,13 @@ Rule Parameter Description
906 908 Prepping Reference
907 909 ******************
908 910
909   -The following is a list of all the prepping functions that are available
  911 +The following is a list of all the prepping methods that are available
910 912 to use:
911 913
912 914 ==================== ========= ===================================================================================================
913 915 Name Parameter Description
914 916 ==================== ========= ===================================================================================================
915   -**xss_clean** No Runs the data through the XSS filtering function, described in the :doc:`Input Class <input>` page.
  917 +**xss_clean** No Runs the data through the XSS filtering method, described in the :doc:`Input Class <input>` page.
916 918 **prep_for_form** No Converts special characters so that HTML data can be shown in a form field without breaking it.
917 919 **prep_url** No Adds "\http://" to URLs if missing.
918 920 **strip_image_tags** No Strips the HTML from image tags leaving the raw URL.
@@ -920,21 +922,21 @@ Name Parameter Description
920 922 ==================== ========= ===================================================================================================
921 923
922 924 .. note:: You can also use any native PHP functions that permits one
923   - parameter, like ``trim()``, ``htmlspecialchars()``, ``urldecode()``, etc.
  925 + parameter, like ``trim()``, ``htmlspecialchars()``, ``urldecode()``,
  926 + etc.
924 927
925   -.. _function-reference:
  928 +.. _class-reference:
926 929
927   -******************
928   -Function Reference
929   -******************
  930 +***************
  931 +Class Reference
  932 +***************
930 933
931 934 .. php:class:: Form_validation
932 935
933   -The following functions are intended for use in your controller
934   -functions.
  936 +The following methods are intended for use in your controller.
935 937
936   -$this->form_validation->set_rules();
937   -====================================
  938 +$this->form_validation->set_rules()
  939 +===================================
938 940
939 941 .. php:method:: set_rules ($field, $label = '', $rules = '')
940 942
@@ -949,8 +951,8 @@ $this->form_validation->set_rules();
949 951 - :ref:`setting-validation-rules`
950 952 - :ref:`saving-groups`
951 953
952   -$this->form_validation->run();
953   -==============================
  954 +$this->form_validation->run()
  955 +=============================
954 956
955 957 .. php:method:: run ($group = '')
956 958
@@ -959,10 +961,10 @@ $this->form_validation->run();
959 961
960 962 Runs the validation routines. Returns boolean TRUE on success and FALSE
961 963 on failure. You can optionally pass the name of the validation group via
962   - the function, as described in: :ref:`saving-groups`
  964 + the method, as described in: :ref:`saving-groups`
963 965
964   -$this->form_validation->set_message();
965   -======================================
  966 +$this->form_validation->set_message()
  967 +=====================================
966 968
967 969 .. php:method:: set_message ($lang, $val = '')
968 970
@@ -972,8 +974,8 @@ $this->form_validation->set_message();
972 974
973 975 Permits you to set custom error messages. See :ref:`setting-error-messages`
974 976
975   -$this->form_validation->set_data();
976   -===================================
  977 +$this->form_validation->set_data()
  978 +==================================
977 979
978 980 .. php:method:: set_data ($data = '')
979 981
@@ -982,16 +984,16 @@ $this->form_validation->set_data();
982 984 Permits you to set an array for validation, instead of using the default
983 985 $_POST array.
984 986
985   -$this->form_validation->reset_validation();
986   -===========================================
  987 +$this->form_validation->reset_validation()
  988 +==========================================
987 989
988 990 .. php:method:: reset_validation ()
989 991
990 992 Permits you to reset the validation when you validate more than one array.
991 993 This method should be called before validating each new array.
992 994
993   -$this->form_validation->error_array();
994   -======================================
  995 +$this->form_validation->error_array()
  996 +=====================================
995 997
996 998 .. php:method:: error_array ()
997 999

0 comments on commit d4eec9f

Please sign in to comment.
Something went wrong with that request. Please try again.