blob: 3da5c31f4a585082fb194ad960abbde86fe0d011 [file] [log] [blame]
Rick Ellis25949532008-08-26 19:48:08 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3<head>
4
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<title>Form Validation : CodeIgniter User Guide</title>
7
8<style type='text/css' media='all'>@import url('../userguide.css');</style>
9<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
10
11<script type="text/javascript" src="../nav/nav.js"></script>
12<script type="text/javascript" src="../nav/prototype.lite.js"></script>
13<script type="text/javascript" src="../nav/moo.fx.js"></script>
14<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
15
16<meta http-equiv='expires' content='-1' />
17<meta http-equiv= 'pragma' content='no-cache' />
18<meta name='robots' content='all' />
19<meta name='author' content='ExpressionEngine Dev Team' />
20<meta name='description' content='CodeIgniter User Guide' />
21</head>
22<body>
23
24<!-- START NAVIGATION -->
25<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
26<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
27<div id="masthead">
28<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
29<tr>
30<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
31<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
32</tr>
33</table>
34</div>
35<!-- END NAVIGATION -->
36
37
38<!-- START BREADCRUMB -->
39<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
40<tr>
41<td id="breadcrumb">
42<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
43<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
44Form Validation
45</td>
46<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
47</tr>
48</table>
49<!-- END BREADCRUMB -->
50
51<br clear="all" />
52
53
54<!-- START CONTENT -->
55<div id="content">
56
57<h1>Form Validation</h1>
58
59<p>CodeIgniter provides a comprehensive form validation and data prepping class that helps minimize the amount of code you'll write.</p>
60
61<p class="important"><strong>Note:</strong>&nbsp; As of CodeIgniter 1.6.4, this Form Validation class supercedes the old Validation class, which is now deprecated. We
62have left the old class in the library so applications currently using it will not break, but you are encouraged to migrate to this new version.</p>
63
64<ul>
65<li><a href="#overview">Overview</a></li>
66<li><a href="#tutorial">Form Validation Tutorial</a>
67
68 <ul>
69 <li><a href="#theform">The Form</a></li>
70 <li><a href="#thesuccesspage">The Success Page</a></li>
71 <li><a href="#thecontroller">The Controller</a></li>
72 <li><a href="#validationrules">Setting Validation Rules</a></li>
73 <li><a href="#validationrulesasarray">Setting Validation Rules Using an Array</a></li>
74 <li><a href="#cascadingrules">Cascading Rules</a></li>
75 <li><a href="#preppingdata">Prepping Data</a></li>
76 <li><a href="#repopulatingform">Re-populating the Form</a></li>
77 <li><a href="#callbacks">Callbacks</a></li>
78 <li><a href="#settingerrors">Setting Error Messages</a></li>
79 <li><a href="#errordelimiters">Changing the Error Delimiters</a></li>
80 <li><a href="#individualerrors">Showing Errors Individually</a></li>
81 <li><a href="#savingtoconfig">Saving Sets of Validation Rules to a Config File</a></li>
Rick Ellis66bc2ad2008-08-26 20:18:17 +000082 <li><a href="#arraysasfields">Using Arrays as Field Names</a></li>
Rick Ellis25949532008-08-26 19:48:08 +000083 </ul>
84</li>
85<li><a href="#rulereference">Rule Reference</a></li>
86<li><a href="#preppingreference">Prepping Reference</a></li>
87<li><a href="#functionreference">Function Reference</a></li>
88<li><a href="#helperreference">Helper Reference</a></li>
89
90</ul>
91
92
93
94
95
96
97<p>&nbsp;</p>
98
99<a name="overview"></a>
100<h1>Overview</h1>
101
102
103<p>Before explaining CodeIgniter's approach to data validation, let's describe the ideal scenario:</p>
104
105<ol>
106<li>A form is displayed.</li>
107<li>You fill it in and submit it.</li>
108<li>If you submitted something invalid, or perhaps missed a required item, the form is redisplayed containing your data
109along with an error message describing the problem.</li>
110<li>This process continues until you have submitted a valid form.</li>
111</ol>
112
113<p>On the receiving end, the script must:</p>
114
115<ol>
116<li>Check for required data.</li>
117<li>Verify that the data is of the correct type, and meets the correct criteria. For example, if a username is submitted
118it must be validated to contain only permitted characters. It must be of a minimum length,
119and not exceed a maximum length. The username can't be someone else's existing username, or perhaps even a reserved word. Etc.</li>
120<li>Sanitize the data for security.</li>
121<li>Pre-format the data if needed (Does the data need to be trimmed? HTML encoded? Etc.)</li>
122<li>Prep the data for insertion in the database.</li>
123</ol>
124
125
126<p>Although there is nothing terribly complex about the above process, it usually requires a significant
127amount of code, and to display error messages, various control structures are usually placed within the form HTML.
128Form validation, while simple to create, is generally very messy and tedious to implement.</p>
129
130<p>&nbsp;</p>
131
132
133<a name="tutorial"></a>
134<h1>Form Validation Tutorial</h1>
135
136<p>What follows is a "hands on" tutorial for implementing CodeIgniters Form Validation.</p>
137
138
139<p>In order to implement form validation you'll need three things:</p>
140
141<ol>
142<li>A <a href="../general/views.html">View</a> file containing a form.</li>
143<li>A View file containing a "success" message to be displayed upon successful submission.</li>
144<li>A <a href="../general/controllers.html">controller</a> function to receive and process the submitted data.</li>
145</ol>
146
147<p>Let's create those three things, using a member sign-up form as the example.</p>
148
149
150
151<a name="theform"></a>
152
153<h2>The Form</h2>
154
155<p>Using a text editor, create a form called <dfn>myform.php</dfn>. In it, place this code and save it to your <samp>applications/views/</samp>
156folder:</p>
157
158
159<textarea class="textarea" style="width:100%" cols="50" rows="30">&lt;html>
160&lt;head>
161&lt;title>My Form&lt;/title>
162&lt;/head>
163&lt;body>
164
165&lt;?php echo validation_errors(); ?>
166
167&lt;?php echo form_open('form'); ?>
168
169&lt;h5>Username&lt;/h5>
170&lt;input type="text" name="username" value="" size="50" />
171
172&lt;h5>Password&lt;/h5>
173&lt;input type="text" name="password" value="" size="50" />
174
175&lt;h5>Password Confirm&lt;/h5>
176&lt;input type="text" name="passconf" value="" size="50" />
177
178&lt;h5>Email Address&lt;/h5>
179&lt;input type="text" name="email" value="" size="50" />
180
181&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>
182
183&lt;/form>
184
185&lt;/body>
186&lt;/html>
187</textarea>
188
189
190
191
192<a name="thesuccesspage"></a>
193<h2>The Success Page</h2>
194
195
196<p>Using a text editor, create a form called <dfn>formsuccess.php</dfn>. In it, place this code and save it to your <samp>applications/views/</samp>
197folder:</p>
198
199
200<textarea class="textarea" style="width:100%" cols="50" rows="14">
201&lt;html>
202&lt;head>
203&lt;title>My Form&lt;/title>
204&lt;/head>
205&lt;body>
206
207&lt;h3>Your form was successfully submitted!&lt;/h3>
208
209&lt;p>&lt;?php echo anchor('form', 'Try it again!'); ?>&lt;/p>
210
211&lt;/body>
212&lt;/html>
213</textarea>
214
215
216
217<a name="thecontroller"></a>
218<h2>The Controller</h2>
219
220<p>Using a text editor, create a controller called <dfn>form.php</dfn>. In it, place this code and save it to your <samp>applications/controllers/</samp>
221folder:</p>
222
223
224<textarea class="textarea" style="width:100%" cols="50" rows="21">&lt;?php
225
226class Form extends Controller {
227
228 function index()
229 {
230 $this->load->helper(array('form', 'url'));
231
232 $this->load->library('form_validation');
233
234 if ($this->form_validation->run() == FALSE)
235 {
236 $this->load->view('myform');
237 }
238 else
239 {
240 $this->load->view('formsuccess');
241 }
242 }
243}
244?></textarea>
245
246
247<h2>Try it!</h2>
248
249<p>To try your form, visit your site using a URL similar to this one:</p>
250
251<code>example.com/index.php/<var>form</var>/</code>
252
253<p><dfn>If you submit the form you should simply see the form reload. That's because you haven't set up any validation
254rules yet.</dfn></p>
255
256<p><strong>Since you haven't told the Form Validation class to validate anything yet, it returns <kbd>FALSE</kbd> (boolean false) by default. The <samp>run()</samp>
257function only returns <kbd>TRUE</kbd> if it has successfully applied your rules without any of them failing.</strong></p>
258
259
260<h2>Explanation</h2>
261
262<p>You'll notice several things about the above pages:</p>
263
264<p>The <dfn>form</dfn> (myform.php) is a standard web form with a couple exceptions:</p>
265
266<ol>
267<li>It uses a <dfn>form helper</dfn> to create the form opening.
268Technically, this isn't necessary. You could create the form using standard HTML. However, the benefit of using the helper
269is that it generates the action URL for you, based on the URL in your config file. This makes your application more portable in the event your URLs change.</li>
270
271<li>At the top of the form you'll notice the following function call:
272<code>&lt;?php echo validation_errors(); ?&gt;</code>
273
274<p>This function will return any error messages sent back by the validator. If there are no messages it returns an empty string.</p>
275</li>
276</ol>
277
278<p>The <dfn>controller</dfn> (form.php) has one function: <dfn>index()</dfn>. This function initializes the validation class and
279loads the <var>form helper</var> and <var>URL helper</var> used by your view files. It also <samp>runs</samp>
280the validation routine. Based on
281whether the validation was successful it either presents the form or the success page.</p>
282
283
284
285
286<a name="validationrules"></a>
287
288<h2>Setting Validation Rules</h2>
289
290<p>CodeIgniter lets you set as many validation rules as you need for a given field, cascading them in order, and it even lets you prep and pre-process the field data
291at the same time. To set validation rules you will use the <dfn>set_rules()</dfn> function:</p>
292
293<code>$this->form_validation->set_rules();</code>
294
295<p>The above function takes <srong>three</strong> parameters as input:</p>
296
297<ol>
298 <li>The field name - the exact name you've given the form field.</li>
299 <li>A "human" name for this field, which will be inserted into the error message. For example, if your field is named "user" you might give it a human name of "Username".</li>
300 <li>The validation rules for this form field.</li>
301</ol>
302
303
304<p><br />Here is an example. In your <dfn>controller</dfn> (form.php), add this code just below the validation initialization function:</p>
305
306<code>
307$this->form_validation->set_rules('username', 'Username', 'required');<br />
308$this->form_validation->set_rules('password', 'Password', 'required');<br />
309$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
310$this->form_validation->set_rules('email', 'Email', 'required');<br />
311</code>
312
313<p>Your controller should now look like this:</p>
314
315<textarea class="textarea" style="width:100%" cols="50" rows="28"><?php
316
317class Form extends Controller {
318
319 function index()
320 {
321 $this->load->helper(array('form', 'url'));
322
323 $this->load->library('form_validation');
324
325 $this->form_validation->set_rules('username', 'Username', 'required');
326 $this->form_validation->set_rules('password', 'Password', 'required');
327 $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
328 $this->form_validation->set_rules('email', 'Email', 'required');
329
330 if ($this->form_validation->run() == FALSE)
331 {
332 $this->load->view('myform');
333 }
334 else
335 {
336 $this->load->view('formsuccess');
337 }
338 }
339}
340?></textarea>
341
342<p><dfn>Now submit the form with the fields blank and you should see the error messages.
343If you submit the form with all the fields populated you'll see your success page.</dfn></p>
344
345<p class="important"><strong>Note:</strong> The form fields are not yet being re-populated with the data when
346there is an error. We'll get to that shortly.</p>
347
348
349
350
351<a name="validationrulesasarray"></a>
352<h2>Setting Rules Using an Array</h2>
353
354<p>Before moving on it should be noted that the rule setting function can be passed an array if you prefer to set all your rules in one action.
355If you use this approach you must name your array keys as indicated:</p>
356
357<code>
358$config = array(<br />
359&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
360&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
361&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
362&nbsp;&nbsp;&nb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nbsp;&nbsp;=> 'Email', <br />
377&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
378&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
379&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
380<br />
381$this->form_validation->set_rules($config);
382</code>
383
384
385
386
387
388
389<a name="cascadingrules"></a>
390<h2>Cascading Rules</h2>
391
392<p>CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting function, like this:</p>
393
394<code>
395$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');<br />
396$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');<br />
397$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
398$this->form_validation->set_rules('email', 'Email', 'required|valid_email');<br />
399</code>
400
401<p>The above code sets the following rules:</p>
402
403<ol>
404<li>The username field be no shorter than 5 characters and no longer than 12.</li>
405<li>The password field must match the password confirmation field.</li>
406<li>The email field must contain a valid email address.</li>
407</ol>
408
409<p>Give it a try! Submit your form without the proper data and you'll see new error messages that correspond to your new rules.
410There are numerous rules available which you can read about in the validation reference.</p>
411
412
413
414<a name="preppingdata"></a>
415<h2>Prepping Data</h2>
416
417<p>In addition to the validation functions like the ones we used above, you can also prep your data in various ways.
418For example, you can set up rules like this:</p>
419
420<code>
421$this->form_validation->set_rules('username', 'Username', '<kbd>trim</kbd>|required|min_length[5]|max_length[12]|<kbd>xss_clean</kbd>');<br />
422$this->form_validation->set_rules('password', 'Password', '<kbd>trim</kbd>|required|matches[passconf]|<kbd>md5</kbd>');<br />
423$this->form_validation->set_rules('passconf', 'Password Confirmation', '<kbd>trim</kbd>|required');<br />
424$this->form_validation->set_rules('email', 'Email', '<kbd>trim</kbd>|required|valid_email');<br />
425</code>
426
427
428<p>In the above example, we are "trimming" the fields, converting the password to MD5, and running the username through
429the "xss_clean" function, which removes malicious data.</p>
430
431<p><strong>Any native PHP function that accepts one parameter can be used as a rule, like <dfn>htmlspecialchars</dfn>,
432<dfn>trim</dfn>, <dfn>MD5</dfn>, etc.</strong></p>
433
434<p><strong>Note:</strong> You will generally want to use the prepping functions <strong>after</strong>
435the validation rules so if there is an error, the original data will be shown in the form.</p>
436
437
438
439
440<a name="repopulatingform"></a>
441<h2>Re-populating the form</h2>
442
443<p>Thus far we have only been dealing with errors. It's time to repopulate the form field with the submitted data. CodeIgniter offers several helper functions
444that permit you to do this. The one you will use most commonly is:</p>
445
446<code>set_value('field name')</code>
447
448
449<p>Open your <dfn>myform.php</dfn> view file and update the <strong>value</strong> in each field using the <dfn>set_value()</dfn> function:</p>
450
451<p><strong>Don't forget to include each. field name in the <dfn>set_value()</dfn> functions!</strong></p>
452
453
454<textarea class="textarea" style="width:100%" cols="50" rows="30">
455&lt;html>
456&lt;head>
457&lt;title>My Form&lt;/title>
458&lt;/head>
459&lt;body>
460
461&lt;?php echo validation_errors(); ?>
462
463&lt;?php echo form_open('form'); ?>
464
465&lt;h5>Username&lt;/h5>
466&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />
467
468&lt;h5>Password&lt;/h5>
469&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />
470
471&lt;h5>Password Confirm&lt;/h5>
472&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />
473
474&lt;h5>Email Address&lt;/h5>
475&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />
476
477&lt;div>&lt;input type="submit" value="Submit" />&lt;/div>
478
479&lt;/form>
480
481&lt;/body>
482&lt;/html>
483</textarea>
484
485
486<p><dfn>Now reload your page and submit the form so that it triggers an error. Your form fields should now be re-populated</dfn></p>
487
488<p class="important"><strong>Note:</strong> The <a href="#functionreference">Function Reference</a> section below contains functions that
489permit you to re-populate &lt;select> menus, radio buttons, and checkboxes.</p>
490
491
492<p><strong>Important Note:</strong> If you use an array as the name of a form field, you must supply it as an array to the function. Example:</p>
493
494<code>&lt;input type="text" name="<kbd>colors[]</kbd>" value="&lt;?php echo set_value('<kbd>colors[]</kbd>'); ?>" size="50" /></code>
495
496
497
498
499
500<a name="callbacks"></a>
501<h2>Callbacks: Your own Validation Functions</h2>
502
503<p>The validation system supports callbacks to your own validation functions. This permits you to extend the validation class
504to meet your needs. For example, if you need to run a database query to see if the user is choosing a unique username, you can
505create a callback function that does that. Let's create a example of this.</p>
506
507<p>In your controller, change the "username" rule to this:</p>
508
509<code>$this->form_validation->set_rules('username', 'Username', '<kbd>callback_username_check</kbd>');</code>
510
511
512<p>Then add a new function called <dfn>username_check</dfn> to your controller. Here's how your controller should now look:</p>
513
514
515<textarea class="textarea" style="width:100%" cols="50" rows="44"><?php
516
517class Form extends Controller {
518
519 function index()
520 {
521 $this->load->helper(array('form', 'url'));
522
523 $this->load->library('form_validation');
524
525 $this->form_validation->set_rules('username', 'Username', 'callback_username_check');
526 $this->form_validation->set_rules('password', 'Password', 'required');
527 $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
528 $this->form_validation->set_rules('email', 'Email', 'required');
529
530 if ($this->form_validation->run() == FALSE)
531 {
532 $this->load->view('myform');
533 }
534 else
535 {
536 $this->load->view('formsuccess');
537 }
538 }
539
540 function username_check($str)
541 {
542 if ($str == 'test')
543 {
544 $this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
545 return FALSE;
546 }
547 else
548 {
549 return TRUE;
550 }
551 }
552
553}
554?></textarea>
555
556<p><dfn>Reload your form and submit it with the word "test" as the username. You can see that the form field data was passed to your
557callback function for you to process.</dfn></p>
558
559<p><strong>To invoke a callback just put the function name in a rule, with "callback_" as the rule prefix.</strong></p>
560
561<p>You can also process the form data that is passed to your callback and return it. If your callback returns anything other then a boolean TRUE/FALSE
562it is assumed that the data is your newly processed form data.</p>
563
564
565
566
567<a name="settingerrors"></a>
568<h2>Setting Error Messages</h2>
569
570
571<p>All of the native error messages are located in the following language file: <dfn>language/english/form_validation_lang.php</dfn></p>
572
573<p>To set your own custom message you can either edit that file, or use the following function:</p>
574
575<code>$this->form_validation->set_message('<var>rule</var>', '<var>Error Message</var>');</code>
576
577<p>Where <var>rule</var> corresponds to the name of a particular rule, and <var>Error Message</var> is the text you would like displayed.</p>
578
579<p>If you include <dfn>%s</dfn> in your error string, it will be replaced with the "human" name you used for your field when you set your rules.</p>
580
581<p>In the "callback" example above, the error message was set by passing the name of the function:</p>
582
583<code>$this->form_validation->set_message('username_check')</code>
584
585<p>You can also override any error message found in the languge file. For example, to change the message for the "required" rule you will do this:</p>
586
587<code>$this->form_validation->set_message('required', 'Your custom message here');</code>
588
589
590
591<a name="errordelimiters"></a>
592<h2>Changing the Error Delimiters</h2>
593
594<p>By default, the Form Validation class adds a paragraph tag (&lt;p&gt;) around each error message shown. You can either change these delimiters globally or
595individually.</p>
596
597<ol>
598
599<li><strong>Changing delimiters Globally</strong>
600
601<p>To globally change the error delimiters, in your controller function, just after loading the Form Validation class, add this:</p>
602
603<code>&lt;?php echo $this->form_validation->set_error_delimiters('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>');</code>
604
605<p>In this example, we've switched to using div tags.</p>
606
607</li>
608
609<li><strong>Changing delimiters Individually</strong></p>
610
611<p>Each of the two error generating functions shown in this tutorial can be supplied their own delimiters as follows:</p>
612
613<code>&lt;?php echo form_error('field name', '<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>
614
615</p>Or:</p>
616
617<code>&lt;?php echo validation_errors('<kbd>&lt;div class="error"></kbd>', '<kbd>&lt;/div></kbd>'); ?></code>
618
619</li>
620</ol>
621
622
623
624
625<a name="individualerrors"></a>
626<h2>Showing Errors Individually</h2>
627
628<p>If you prefer to show an error message next to each form field, rather than as a list, you can use the <dfn>form_error()</dfn> function.</p>
629
630<p>Try it! Change your form so that it looks like this:</p>
631
632<textarea class="textarea" style="width:100%" cols="50" rows="18">
633&lt;h5>Username&lt;/h5>
634&lt;?php echo form_error('username'); ?>
635&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?>" size="50" />
636
637&lt;h5>Password&lt;/h5>
638&lt;?php echo form_error('password'); ?>
639&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?>" size="50" />
640
641&lt;h5>Password Confirm&lt;/h5>
642&lt;?php echo form_error('passconf'); ?>
643&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?>" size="50" />
644
645&lt;h5>Email Address&lt;/h5>
646&lt;?php echo form_error('email'); ?>
647&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?>" size="50" />
648</textarea>
649
650<p>If there are no errors, nothing will be shown. If there is an error, the message will appear.</p>
651
652<p><strong>Important Note:</strong> If you use an array as the name of a form field, you must supply it as an array to the function. Example:</p>
653
654<code>&lt;?php echo form_error('<kbd>options[size]</kbd>'); ?><br />
655&lt;input type="text" name="<kbd>options[size]</kbd>" value="&lt;?php echo set_value("<kbd>options[size]</kbd>"); ?>" size="50" />
656</code>
657
658
659
660
661
662<p>&nbsp;</p>
663
664
665<a name="savingtoconfig"></a>
666<h1>Saving Sets of Validation Rules to a Config File</h1>
667
668<p>A nice feature of the Form Validation class is that it permits you to store all your validation rules for your entire application in a config file. You
669can organize these rules into "groups". These groups can either be loaded automatically when a matching controller/function is called, or
670you can manually call each set as needed.</p>
671
672<h3>How to save your rules</h3>
673
674<p>To store your validation rules, simply create a file named <kbd>form_validation.php</kbd> in your <dfn>application/config/</dfn> folder.
675In that file you will place an array named <kbd>$config</kbd> with your rules. As shown earlier, the validation array will have this prototype:</p>
676
677<code>
678$config = array(<br />
679&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
680&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'username', <br />
681&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Username', <br />
682&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
683&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
684&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
685&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'password', <br />
686&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password', <br />
687&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
688&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
689&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
690&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'passconf', <br />
691&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Password Confirmation', <br />
692&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
693&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),&nbsp;&nbsp;&nbsp;<br />
694&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
695&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field'&nbsp;&nbsp;&nbsp;=> 'email', <br />
696&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label'&nbsp;&nbsp;&nbsp;=> 'Email', <br />
697&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules'&nbsp;&nbsp;&nbsp;=> 'required'<br />
698&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
699&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
700</code>
701
702<p><dfn>Your validation rule file will be loaded automatically and used when you call the run() function.</dfn></p>
703
704<p class="important">Please note that you MUST name your array $config.</p>
705
706<h3>Creating Sets of Rules</h3>
707
708<p>In order to organize your rules into "sets" requires that you place them into "sub arrays". Consider the following example, showing two sets of rules.
709We've arbitrarily called these two rules "signup" and "email". You can name your rules anything you want:</p>
710
711
712<code>$config = array(<br />
713&nbsp;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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
757&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
758</code>
759
760
761<h3>Calling a Specific Rule Group</h3>
762
763<p>In order to call a specific group you will pass its name to the <kbd>run()</kbd> function. For example, to call the <kbd>signup</kbd> rule you will do this:</p>
764
765<code>
766if ($this->form_validation->run('<kbd>signup</kbd>') == FALSE)<br />
767{<br />
768&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
769}<br />
770else<br />
771{<br />
772&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
773}<br />
774</code>
775
776
777
778<h3>Associating a Controller Function with a Rule Group</h3>
779
780<p>An alternate (and more automatic) method of calling a rule group is to name it according to the controller class/function you intend to use it with. For example, let's say you
781have a controller named <kbd>Member</kbd> and a function named <kbd>signup</kbd>. Here's what your class might look like:</p>
782
783<code>
784&lt;?php<br /><br />
785class <kbd>Member</kbd> extends Controller {<br />
786<br />
787&nbsp;&nbsp;&nbsp;function <kbd>signup</kbd>()<br />
788&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
789&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('form_validation');<br />
790&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
791&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($this->form_validation->run() == FALSE)<br />
792&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
793&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('myform');<br />
794&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
795&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
796&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
797&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('formsuccess');<br />
798&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
799&nbsp;&nbsp;&nbsp;}<br />
800}<br />
801?></code>
802
803<p>In your validation config file, you will name your rule group <kbd>member/signup</kbd>:
804
805
806<code>$config = array(<br />
807&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<kbd>member/signup</kbd>' = array(<br />
808&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
809&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field' => 'username',<br />
810&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rules' => 'required'<br />
827&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
828&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
829&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
830</code>
831
832<p><dfn>When a rule group is named identically to a controller class/function it will be used automatically when the run() function is invoked from that class/function.</dfn></p>
833
Rick Ellis66bc2ad2008-08-26 20:18:17 +0000834<p>&nbsp;</p>
Rick Ellis25949532008-08-26 19:48:08 +0000835
836
Rick Ellis66bc2ad2008-08-26 20:18:17 +0000837<a name="arraysasfields"></a>
838<h1>Using Arrays as Field Names</h1>
Rick Ellis25949532008-08-26 19:48:08 +0000839
Rick Ellis66bc2ad2008-08-26 20:18:17 +0000840<p>The Form Validation class supports the use of arrays as field names. Consider this example:</p>
841
842<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="" size="50" /></code>
843
844<p>If you do use an array as a field name, you must use the EXACT array name in the <a href="#helperreference">Helper Functions</a> that require the field name,
845and as your Validation Rule field name.</p>
846
847<p>For example, to set a rule for the above field you would use:</p>
848
849<code>$this->form_validation->set_rules('<kbd>options[]</kbd>', 'Options', 'required');</code>
850
851<p>Or, to show an error for the above field you would use:</p>
852
853<code>&lt;?php echo form_error('<kbd>options[]</kbd>'); ?></code>
854
855<p>Or to re-populate the field you would use:</p>
856
857<code>&lt;input type="text" name="<kbd>options[]</kbd>" value="<kbd>&lt;?php echo set_value('<kbd>options[]</kbd>'); ?></kbd>" size="50" /></code>
858
859<p>You can use multidimensional arrays as field names as well. For example:</p>
860
861<code>&lt;input type="text" name="<kbd>options[size]</kbd>" value="" size="50" /></code>
862
863<p>Or even:</p>
864
865<code>&lt;input type="text" name="<kbd>sports[nba][basketball]</kbd>" value="" size="50" /></code>
866
867<p>As with our first example, you must use the exact array name in the helper functions:</p>
868
869<code>&lt;?php echo form_error('<kbd>sports[nba][basketball]</kbd>'); ?></code>
870
871<p>If you are using checkboxes (or other fields) that have multiple options, don't forget to leave an empty bracket after each option, so that all selections will be added to the
872POST array:</p>
873
874<code>
875&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="red" /><br />
876&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="blue" /><br />
877&lt;input type="checkbox" name="<kbd>options[]</kbd>" value="green" />
878</code>
879
880<p>Or if you use a multidimensional array:</p>
881
882<code>
883&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="red" /><br />
884&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="blue" /><br />
885&lt;input type="checkbox" name="<kbd>options[color][]</kbd>" value="green" />
886</code>
887
888<p>When you use a helper function you'll include the bracket as well:</p>
889
890<code>&lt;?php echo form_error('<kbd>options[color][]</kbd>'); ?></code>
Rick Ellis25949532008-08-26 19:48:08 +0000891
892
893
894
895<p>&nbsp;</p>
896
897
898<a name="rulereference"></a>
899<h1>Rule Reference</h1>
900
901<p>The following is a list of all the native rules that are available to use:</p>
902
903
904
905<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
906<tr>
907<th>Rule</th>
908<th>Parameter</th>
909<th>Description</th>
910<th>Example</th>
911</tr><tr>
912
913<td class="td"><strong>required</strong></td>
914<td class="td">No</td>
915<td class="td">Returns FALSE if the form element is empty.</td>
916<td class="td">&nbsp;</td>
917</tr><tr>
918
919<td class="td"><strong>matches</strong></td>
920<td class="td">Yes</td>
921<td class="td">Returns FALSE if the form element does not match the one in the parameter.</td>
922<td class="td">matches[form_item]</td>
923</tr><tr>
924
925<td class="td"><strong>min_length</strong></td>
926<td class="td">Yes</td>
927<td class="td">Returns FALSE if the form element is shorter then the parameter value.</td>
928<td class="td">min_length[6]</td>
929</tr><tr>
930
931<td class="td"><strong>max_length</strong></td>
932<td class="td">Yes</td>
933<td class="td">Returns FALSE if the form element is longer then the parameter value.</td>
934<td class="td">max_length[12]</td>
935</tr><tr>
936
937<td class="td"><strong>exact_length</strong></td>
938<td class="td">Yes</td>
939<td class="td">Returns FALSE if the form element is not exactly the parameter value.</td>
940<td class="td">exact_length[8]</td>
941</tr><tr>
942
943<td class="td"><strong>alpha</strong></td>
944<td class="td">No</td>
945<td class="td">Returns FALSE if the form element contains anything other than alphabetical characters.</td>
946<td class="td">&nbsp;</td>
947</tr><tr>
948
949<td class="td"><strong>alpha_numeric</strong></td>
950<td class="td">No</td>
951<td class="td">Returns FALSE if the form element contains anything other than alpha-numeric characters.</td>
952<td class="td">&nbsp;</td>
953</tr><tr>
954
955<td class="td"><strong>alpha_dash</strong></td>
956<td class="td">No</td>
957<td class="td">Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.</td>
958<td class="td">&nbsp;</td>
959</tr>
960
961<tr>
962<td class="td"><strong>numeric</strong></td>
963<td class="td">No</td>
964<td class="td">Returns FALSE if the form element contains anything other than numeric characters.</td>
965<td class="td">&nbsp;</td>
966</tr>
967
968<tr>
969<td class="td"><strong>integer</strong></td>
970<td class="td">No</td>
971<td class="td">Returns FALSE if the form element contains anything other than an integer.</td>
972<td class="td">&nbsp;</td>
973</tr>
974
975<tr>
976<td class="td"><strong>is_natural</strong></td>
977<td class="td">No</td>
978<td class="td">Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc.</td>
979<td class="td">&nbsp;</td>
980</tr>
981
982<tr>
983<td class="td"><strong>is_natural_no_zero</strong></td>
984<td class="td">No</td>
985<td class="td">Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc.</td>
986<td class="td">&nbsp;</td>
987</tr>
988
989<tr>
990<td class="td"><strong>valid_email</strong></td>
991<td class="td">No</td>
992<td class="td">Returns FALSE if the form element does not contain a valid email address.</td>
993<td class="td">&nbsp;</td>
994</tr>
995
996<tr>
997<td class="td"><strong>valid_emails</strong></td>
998<td class="td">No</td>
999<td class="td">Returns FALSE if any value provided in a comma separated list is not a valid email.</td>
1000<td class="td">&nbsp;</td>
1001</tr>
1002
1003<tr>
1004<td class="td"><strong>valid_ip</strong></td>
1005<td class="td">No</td>
1006<td class="td">Returns FALSE if the supplied IP is not valid.</td>
1007<td class="td">&nbsp;</td>
1008</tr>
1009
1010<tr>
1011<td class="td"><strong>valid_base64</strong></td>
1012<td class="td">No</td>
1013<td class="td">Returns FALSE if the supplied string contains anything other than valid Base64 characters.</td>
1014<td class="td">&nbsp;</td>
1015</tr>
1016
1017
1018</table>
1019
1020<p><strong>Note:</strong> These rules can also be called as discrete functions. For example:</p>
1021
1022<code>$this->form_validation->required($string);</code>
1023
1024<p class="important"><strong>Note:</strong> You can also use any native PHP functions that permit one parameter.</p>
1025
1026
1027
1028<p>&nbsp;</p>
1029
1030<a name="preppingreference"></a>
1031<h1>Prepping Reference</h1>
1032
1033<p>The following is a list of all the prepping functions that are available to use:</p>
1034
1035
1036
1037<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
1038<tr>
1039<th>Name</th>
1040<th>Parameter</th>
1041<th>Description</th>
1042</tr><tr>
1043
1044<td class="td"><strong>xss_clean</strong></td>
1045<td class="td">No</td>
1046<td class="td">Runs the data through the XSS filtering function, described in the <a href="input.html">Input Class</a> page.</td>
1047</tr><tr>
1048
1049<td class="td"><strong>prep_for_form</strong></td>
1050<td class="td">No</td>
1051<td class="td">Converts special characters so that HTML data can be shown in a form field without breaking it.</td>
1052</tr><tr>
1053
1054<td class="td"><strong>prep_url</strong></td>
1055<td class="td">No</td>
1056<td class="td">Adds "http://" to URLs if missing.</td>
1057</tr><tr>
1058
1059<td class="td"><strong>strip_image_tags</strong></td>
1060<td class="td">No</td>
1061<td class="td">Strips the HTML from image tags leaving the raw URL.</td>
1062</tr><tr>
1063
1064<td class="td"><strong>encode_php_tags</strong></td>
1065<td class="td">No</td>
1066<td class="td">Converts PHP tags to entities.</td>
1067</tr>
1068
1069</table>
1070
1071<p class="important"><strong>Note:</strong> You can also use any native PHP functions that permit one parameter,
1072like <kbd>trim</kbd>, <kbd>htmlspecialchars</kbd>, <kbd>urldecode</kbd>, etc.</p>
1073
1074
1075
1076
1077
1078
1079
1080<p>&nbsp;</p>
1081
1082<a name="functionreference"></a>
1083<h1>Function Reference</h1>
1084
Rick Ellisb1eee352008-08-26 19:56:48 +00001085<p>The following functions are intended for use in your controller functions.</p>
1086
Rick Ellis25949532008-08-26 19:48:08 +00001087<h2>$this->form_validation->set_rule();</h2>
1088
1089<p>Permits you to set validation rules, as described in the tutorial sections above:</p>
1090
1091<ul>
1092<li><a href="#validationrules">Setting Validation Rules</a></li>
1093<li><a href="#savingtoconfig">Saving Groups of Validation Rules to a Config File</a></li>
1094</ul>
1095
1096
1097<h2>$this->form_validation->run();</h2>
1098
1099<p>Runs the validation routines. Returns boolean TRUE on success and FALSE on failure. You can optionally pass the name of the validation
1100group via the function, as described in: <a href="#savingtoconfig">Saving Groups of Validation Rules to a Config File</a>.</p>
1101
1102
1103<h2>$this->form_validation->set_message();</h2>
1104
1105<p>Permits you to set custom error messages. See <a href="#settingerrors">Setting Error Messages</a> above.</p>
1106
1107
1108<p>&nbsp;</p>
1109
1110<a name="helperreference"></a>
1111<h1>Helper Reference</h1>
1112
1113<p>The following helper functions are available for use in the view files containing your forms. Note that these are procedural functions, so they
1114<strong>do not</strong> require you to prepend them with $this->form_validation.</p>
1115
1116<h2>form_error()</h2>
1117
1118<p>Shows an individual error message associated with the field name supplied to the function. Example:</p>
1119
1120<code>&lt;?php echo form_error('username'); ?></code>
1121
1122<p>The error delimiters can be optionally specified. See the <a href="#errordelimiters">Changing the Error Delimiters</a> section above.</p>
1123
1124
1125
1126<h2>validation_errors()</h2>
1127<p>Shows all error messages as a string: Example:</p>
1128
1129<code>&lt;?php echo validation_errors(); ?></code>
1130
1131<p>The error delimiters can be optionally specified. See the <a href="#errordelimiters">Changing the Error Delimiters</a> section above.</p>
1132
1133
1134
1135<h2>set_value()</h2>
1136
1137<p>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.
1138The second (optional) parameter allows you to set a default value for the form. Example:</p>
1139
1140<code>&lt;input type="text" name="quantity" value="<dfn>&lt;?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>
1141
1142<p>The above form will show "0" when loaded for the firs time.</p>
1143
1144<h2>set_select()</h2>
1145
1146<p>If you use a <dfn>&lt;select></dfn> menu, this function permits you to display the menu item that was selected. The first parameter
1147must contain the name of the select menu, the second parameter must contain the value of
1148each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
1149
1150<p>Example:</p>
1151
1152<code>
1153&lt;select name="myselect"><br />
1154&lt;option value="one" <dfn>&lt;?php echo set_select('myselect', 'one', TRUE); ?></dfn> >One&lt;/option><br />
1155&lt;option value="two" <dfn>&lt;?php echo set_select('myselect', 'two'); ?></dfn> >Two&lt;/option><br />
1156&lt;option value="three" <dfn>&lt;?php echo set_select('myselect', 'three'); ?></dfn> >Three&lt;/option><br />
1157&lt;/select>
1158</code>
1159
1160
1161<h2>set_checkbox()</h2>
1162
1163<p>Permits you to display a checkbox in the state it was submitted. The first parameter
1164must 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:</p>
1165
Rick Ellis66bc2ad2008-08-26 20:18:17 +00001166<code>&lt;input type="checkbox" name="mycheck[]" value="1" <dfn>&lt;?php echo set_checkbox('mycheck[]', '1'); ?></dfn> /><br />
1167&lt;input type="checkbox" name="mycheck[]" value="2" <dfn>&lt;?php echo set_checkbox('mycheck[]', '2'); ?></dfn> /></code>
Rick Ellis25949532008-08-26 19:48:08 +00001168
1169
1170<h2>set_radio()</h2>
1171
1172<p>Permits you to display radio buttons in the state they were submitted. This function is identical to the <strong>set_checkbox()</strong> function above.</p>
1173
1174<code>&lt;input type="radio" name="myradio" value="1" <dfn>&lt;?php echo set_radio('myradio', '1', TRUE); ?></dfn> /><br />
1175&lt;input type="radio" name="myradio" value="2" <dfn>&lt;?php echo set_radio('myradio', '2'); ?></dfn> /></code>
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185</div>
1186<!-- END CONTENT -->
1187
1188
1189<div id="footer">
1190<p>
1191Previous Topic:&nbsp;&nbsp;<a href="file_uploading.html">File Uploading Class</a>
1192&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
1193<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
1194<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
1195Next Topic:&nbsp;&nbsp;<a href="ftp.html">FTP Class</a>
1196</p>
1197<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
1198</div>
1199
1200</body>
1201</html>