blob: 4716e4975a4743bd99eca3e9fd68770f54e73a3d [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * CodeIgniter Form Helpers
20 *
21 * @package CodeIgniter
22 * @subpackage Helpers
23 * @category Helpers
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/form_helper.html
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * Form Declaration
32 *
33 * Creates the opening portion of the form.
34 *
35 * @access public
36 * @param string the URI segments of the form destination
37 * @param array a key/value pair of attributes
38 * @param array a key/value pair hidden data
39 * @return string
40 */
41if ( ! function_exists('form_open'))
42{
43 function form_open($action = '', $attributes = '', $hidden = array())
44 {
45 $CI =& get_instance();
46
47 if ($attributes == '')
48 {
49 $attributes = 'method="post"';
50 }
51
52 $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action;
53
54 $form = '<form action="'.$action.'"';
55
56 $form .= _attributes_to_string($attributes, TRUE);
57
58 $form .= '>';
59
60 if (is_array($hidden) AND count($hidden) > 0)
61 {
62 $form .= form_hidden($hidden);
63 }
64
65 return $form;
66 }
67}
68
69// ------------------------------------------------------------------------
70
71/**
72 * Form Declaration - Multipart type
73 *
74 * Creates the opening portion of the form, but with "multipart/form-data".
75 *
76 * @access public
77 * @param string the URI segments of the form destination
78 * @param array a key/value pair of attributes
79 * @param array a key/value pair hidden data
80 * @return string
81 */
82if ( ! function_exists('form_open_multipart'))
83{
84 function form_open_multipart($action, $attributes = array(), $hidden = array())
85 {
86 $attributes['enctype'] = 'multipart/form-data';
87 return form_open($action, $attributes, $hidden);
88 }
89}
90
91// ------------------------------------------------------------------------
92
93/**
94 * Hidden Input Field
95 *
96 * Generates hidden fields. You can pass a simple key/value string or an associative
97 * array with multiple values.
98 *
99 * @access public
100 * @param mixed
101 * @param string
102 * @return string
103 */
104if ( ! function_exists('form_hidden'))
105{
Robin Sowell57fe4102009-03-26 18:58:46 +0000106 function form_hidden($name, $value = '', $recursing = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000107 {
Robin Sowell57fe4102009-03-26 18:58:46 +0000108 static $form;
109
110 if ($recursing === FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000111 {
Robin Sowell57fe4102009-03-26 18:58:46 +0000112 $form = "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000113 }
114
Robin Sowell57fe4102009-03-26 18:58:46 +0000115 if (is_array($name))
Derek Allard2067d1a2008-11-13 22:59:24 +0000116 {
Robin Sowell57fe4102009-03-26 18:58:46 +0000117 foreach ($name as $key => $val)
118 {
119 form_hidden($key, $val, TRUE);
120 }
121 return $form;
122 }
123
124 if ( ! is_array($value))
125 {
126 $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value).'" />'."\n";
127 }
128 else
129 {
130 foreach ($value as $k => $v)
131 {
132 $k = (is_int($k)) ? '' : $k;
133 form_hidden($name.'['.$k.']', $v, TRUE);
134 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000135 }
136
137 return $form;
138 }
139}
140
141// ------------------------------------------------------------------------
142
143/**
144 * Text Input Field
145 *
146 * @access public
147 * @param mixed
148 * @param string
149 * @param string
150 * @return string
151 */
152if ( ! function_exists('form_input'))
153{
154 function form_input($data = '', $value = '', $extra = '')
155 {
156 $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
157
158 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
159 }
160}
161
162// ------------------------------------------------------------------------
163
164/**
165 * Password Field
166 *
167 * Identical to the input function but adds the "password" type
168 *
169 * @access public
170 * @param mixed
171 * @param string
172 * @param string
173 * @return string
174 */
175if ( ! function_exists('form_password'))
176{
177 function form_password($data = '', $value = '', $extra = '')
178 {
179 if ( ! is_array($data))
180 {
181 $data = array('name' => $data);
182 }
183
184 $data['type'] = 'password';
185 return form_input($data, $value, $extra);
186 }
187}
188
189// ------------------------------------------------------------------------
190
191/**
192 * Upload Field
193 *
194 * Identical to the input function but adds the "file" type
195 *
196 * @access public
197 * @param mixed
198 * @param string
199 * @param string
200 * @return string
201 */
202if ( ! function_exists('form_upload'))
203{
204 function form_upload($data = '', $value = '', $extra = '')
205 {
206 if ( ! is_array($data))
207 {
208 $data = array('name' => $data);
209 }
210
211 $data['type'] = 'file';
212 return form_input($data, $value, $extra);
213 }
214}
215
216// ------------------------------------------------------------------------
217
218/**
219 * Textarea field
220 *
221 * @access public
222 * @param mixed
223 * @param string
224 * @param string
225 * @return string
226 */
227if ( ! function_exists('form_textarea'))
228{
229 function form_textarea($data = '', $value = '', $extra = '')
230 {
231 $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
232
233 if ( ! is_array($data) OR ! isset($data['value']))
234 {
235 $val = $value;
236 }
237 else
238 {
239 $val = $data['value'];
240 unset($data['value']); // textareas don't use the value attribute
241 }
242
243 return "<textarea "._parse_form_attributes($data, $defaults).$extra.">".$val."</textarea>";
244 }
245}
246
247// ------------------------------------------------------------------------
248
249/**
Derek Jones26399292009-04-08 16:14:17 +0000250 * Multi-select menu
251 *
252 * @access public
253 * @param string
254 * @param array
255 * @param mixed
256 * @param string
257 * @return type
258 */
259if (! function_exists('form_multiselect'))
260{
261 function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '')
262 {
263 if ( ! strpos($extra, 'multiple'))
264 {
265 $extra .= ' multiple="multiple"';
266 }
267
268 return form_dropdown($name, $options, $selected, $extra);
269 }
270}
271
272// --------------------------------------------------------------------
273
274/**
Derek Allard2067d1a2008-11-13 22:59:24 +0000275 * Drop-down Menu
276 *
277 * @access public
278 * @param string
279 * @param array
280 * @param string
281 * @param string
282 * @return string
283 */
284if ( ! function_exists('form_dropdown'))
285{
286 function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
287 {
288 if ( ! is_array($selected))
289 {
290 $selected = array($selected);
291 }
292
293 // If no selected state was submitted we will attempt to set it automatically
294 if (count($selected) === 0)
295 {
296 // If the form name appears in the $_POST array we have a winner!
297 if (isset($_POST[$name]))
298 {
299 $selected = array($_POST[$name]);
300 }
301 }
302
303 if ($extra != '') $extra = ' '.$extra;
304
305 $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
306
307 $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
Robin Sowell57fe4102009-03-26 18:58:46 +0000308
Derek Allard2067d1a2008-11-13 22:59:24 +0000309 foreach ($options as $key => $val)
310 {
311 $key = (string) $key;
Derek Allard2067d1a2008-11-13 22:59:24 +0000312
Derek Allard78a5fc92009-02-05 16:34:35 +0000313 if (is_array($val))
314 {
315 $form .= '<optgroup label="'.$key.'">'."\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000316
Derek Allard78a5fc92009-02-05 16:34:35 +0000317 foreach ($val as $optgroup_key => $optgroup_val)
318 {
Derek Allard86a840c2009-02-05 17:31:58 +0000319 $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
Derek Allard78a5fc92009-02-05 16:34:35 +0000320
321 $form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
322 }
323
324 $form .= '</optgroup>'."\n";
325 }
326 else
327 {
328 $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
329
330 $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
331 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000332 }
333
334 $form .= '</select>';
335
336 return $form;
337 }
338}
339
340// ------------------------------------------------------------------------
341
342/**
343 * Checkbox Field
344 *
345 * @access public
346 * @param mixed
347 * @param string
348 * @param bool
349 * @param string
350 * @return string
351 */
352if ( ! function_exists('form_checkbox'))
353{
354 function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
355 {
356 $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
357
358 if (is_array($data) AND array_key_exists('checked', $data))
359 {
360 $checked = $data['checked'];
361
362 if ($checked == FALSE)
363 {
364 unset($data['checked']);
365 }
366 else
367 {
368 $data['checked'] = 'checked';
369 }
370 }
371
372 if ($checked == TRUE)
373 {
374 $defaults['checked'] = 'checked';
375 }
376 else
377 {
378 unset($defaults['checked']);
379 }
380
381 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
382 }
383}
384
385// ------------------------------------------------------------------------
386
387/**
388 * Radio Button
389 *
390 * @access public
391 * @param mixed
392 * @param string
393 * @param bool
394 * @param string
395 * @return string
396 */
397if ( ! function_exists('form_radio'))
398{
399 function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
400 {
401 if ( ! is_array($data))
402 {
403 $data = array('name' => $data);
404 }
405
406 $data['type'] = 'radio';
407 return form_checkbox($data, $value, $checked, $extra);
408 }
409}
410
411// ------------------------------------------------------------------------
412
413/**
414 * Submit Button
415 *
416 * @access public
417 * @param mixed
418 * @param string
419 * @param string
420 * @return string
421 */
422if ( ! function_exists('form_submit'))
423{
424 function form_submit($data = '', $value = '', $extra = '')
425 {
426 $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
427
428 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
429 }
430}
431
432// ------------------------------------------------------------------------
433
434/**
435 * Reset Button
436 *
437 * @access public
438 * @param mixed
439 * @param string
440 * @param string
441 * @return string
442 */
443if ( ! function_exists('form_reset'))
444{
445 function form_reset($data = '', $value = '', $extra = '')
446 {
447 $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
448
449 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
450 }
451}
452
453// ------------------------------------------------------------------------
454
455/**
456 * Form Button
457 *
458 * @access public
459 * @param mixed
460 * @param string
461 * @param string
462 * @return string
463 */
464if ( ! function_exists('form_button'))
465{
466 function form_button($data = '', $content = '', $extra = '')
467 {
Derek Allard904094a2009-02-10 14:00:34 +0000468 $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
Derek Allard2067d1a2008-11-13 22:59:24 +0000469
470 if ( is_array($data) AND isset($data['content']))
471 {
472 $content = $data['content'];
473 unset($data['content']); // content is not an attribute
474 }
475
476 return "<button "._parse_form_attributes($data, $defaults).$extra.">".$content."</button>";
477 }
478}
479
480// ------------------------------------------------------------------------
481
482/**
483 * Form Label Tag
484 *
485 * @access public
486 * @param string The text to appear onscreen
487 * @param string The id the label applies to
488 * @param string Additional attributes
489 * @return string
490 */
491if ( ! function_exists('form_label'))
492{
493 function form_label($label_text = '', $id = '', $attributes = array())
494 {
495
496 $label = '<label';
497
498 if ($id != '')
499 {
500 $label .= " for=\"$id\"";
501 }
502
503 if (is_array($attributes) AND count($attributes) > 0)
504 {
505 foreach ($attributes as $key => $val)
506 {
507 $label .= ' '.$key.'="'.$val.'"';
508 }
509 }
510
511 $label .= ">$label_text</label>";
512
513 return $label;
514 }
515}
516
517// ------------------------------------------------------------------------
518/**
519 * Fieldset Tag
520 *
521 * Used to produce <fieldset><legend>text</legend>. To close fieldset
522 * use form_fieldset_close()
523 *
524 * @access public
525 * @param string The legend text
526 * @param string Additional attributes
527 * @return string
528 */
529if ( ! function_exists('form_fieldset'))
530{
531 function form_fieldset($legend_text = '', $attributes = array())
532 {
533 $fieldset = "<fieldset";
534
535 $fieldset .= _attributes_to_string($attributes, FALSE);
536
537 $fieldset .= ">\n";
538
539 if ($legend_text != '')
540 {
541 $fieldset .= "<legend>$legend_text</legend>\n";
542 }
543
544 return $fieldset;
545 }
546}
547
548// ------------------------------------------------------------------------
549
550/**
551 * Fieldset Close Tag
552 *
553 * @access public
554 * @param string
555 * @return string
556 */
557if ( ! function_exists('form_fieldset_close'))
558{
559 function form_fieldset_close($extra = '')
560 {
561 return "</fieldset>".$extra;
562 }
563}
564
565// ------------------------------------------------------------------------
566
567/**
568 * Form Close Tag
569 *
570 * @access public
571 * @param string
572 * @return string
573 */
574if ( ! function_exists('form_close'))
575{
576 function form_close($extra = '')
577 {
578 return "</form>".$extra;
579 }
580}
581
582// ------------------------------------------------------------------------
583
584/**
585 * Form Prep
586 *
587 * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
588 *
589 * @access public
590 * @param string
591 * @return string
592 */
593if ( ! function_exists('form_prep'))
594{
595 function form_prep($str = '')
596 {
597 // if the field name is an array we do this recursively
598 if (is_array($str))
599 {
600 foreach ($str as $key => $val)
601 {
602 $str[$key] = form_prep($val);
603 }
604
605 return $str;
606 }
607
608 if ($str === '')
609 {
610 return '';
611 }
612
613 $temp = '__TEMP_AMPERSANDS__';
614
615 // Replace entities to temporary markers so that
616 // htmlspecialchars won't mess them up
617 $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
618 $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
619
620 $str = htmlspecialchars($str);
621
622 // In case htmlspecialchars misses these.
623 $str = str_replace(array("'", '"'), array("&#39;", "&quot;"), $str);
624
625 // Decode the temp markers back to entities
626 $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
627 $str = preg_replace("/$temp(\w+);/","&\\1;",$str);
628
629 return $str;
630 }
631}
632
633// ------------------------------------------------------------------------
634
635/**
636 * Form Value
637 *
638 * Grabs a value from the POST array for the specified field so you can
639 * re-populate an input field or textarea. If Form Validation
640 * is active it retrieves the info from the validation class
641 *
642 * @access public
643 * @param string
644 * @return mixed
645 */
646if ( ! function_exists('set_value'))
647{
648 function set_value($field = '', $default = '')
649 {
650 if (FALSE === ($OBJ =& _get_validation_object()))
651 {
652 if ( ! isset($_POST[$field]))
653 {
654 return $default;
655 }
656
657 return form_prep($_POST[$field]);
658 }
659
660 return form_prep($OBJ->set_value($field, $default));
661 }
662}
663
664// ------------------------------------------------------------------------
665
666/**
667 * Set Select
668 *
669 * Let's you set the selected value of a <select> menu via data in the POST array.
670 * If Form Validation is active it retrieves the info from the validation class
671 *
672 * @access public
673 * @param string
674 * @param string
675 * @param bool
676 * @return string
677 */
678if ( ! function_exists('set_select'))
679{
680 function set_select($field = '', $value = '', $default = FALSE)
681 {
682 $OBJ =& _get_validation_object();
683
684 if ($OBJ === FALSE)
685 {
686 if ( ! isset($_POST[$field]))
687 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000688 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000689 {
690 return ' selected="selected"';
691 }
692 return '';
693 }
694
695 $field = $_POST[$field];
696
697 if (is_array($field))
698 {
699 if ( ! in_array($value, $field))
700 {
701 return '';
702 }
703 }
704 else
705 {
706 if (($field == '' OR $value == '') OR ($field != $value))
707 {
708 return '';
709 }
710 }
711
712 return ' selected="selected"';
713 }
714
715 return $OBJ->set_select($field, $value, $default);
716 }
717}
718
719// ------------------------------------------------------------------------
720
721/**
722 * Set Checkbox
723 *
724 * Let's you set the selected value of a checkbox via the value in the POST array.
725 * If Form Validation is active it retrieves the info from the validation class
726 *
727 * @access public
728 * @param string
729 * @param string
730 * @param bool
731 * @return string
732 */
733if ( ! function_exists('set_checkbox'))
734{
735 function set_checkbox($field = '', $value = '', $default = FALSE)
736 {
737 $OBJ =& _get_validation_object();
738
739 if ($OBJ === FALSE)
740 {
741 if ( ! isset($_POST[$field]))
742 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000743 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000744 {
745 return ' checked="checked"';
746 }
747 return '';
748 }
749
750 $field = $_POST[$field];
751
752 if (is_array($field))
753 {
754 if ( ! in_array($value, $field))
755 {
756 return '';
757 }
758 }
759 else
760 {
761 if (($field == '' OR $value == '') OR ($field != $value))
762 {
763 return '';
764 }
765 }
766
767 return ' checked="checked"';
768 }
769
770 return $OBJ->set_checkbox($field, $value, $default);
771 }
772}
773
774// ------------------------------------------------------------------------
775
776/**
777 * Set Radio
778 *
779 * Let's you set the selected value of a radio field via info in the POST array.
780 * If Form Validation is active it retrieves the info from the validation class
781 *
782 * @access public
783 * @param string
784 * @param string
785 * @param bool
786 * @return string
787 */
788if ( ! function_exists('set_radio'))
789{
790 function set_radio($field = '', $value = '', $default = FALSE)
791 {
792 $OBJ =& _get_validation_object();
793
794 if ($OBJ === FALSE)
795 {
796 if ( ! isset($_POST[$field]))
797 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000798 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000799 {
800 return ' checked="checked"';
801 }
802 return '';
803 }
804
805 $field = $_POST[$field];
806
807 if (is_array($field))
808 {
809 if ( ! in_array($value, $field))
810 {
811 return '';
812 }
813 }
814 else
815 {
816 if (($field == '' OR $value == '') OR ($field != $value))
817 {
818 return '';
819 }
820 }
821
822 return ' checked="checked"';
823 }
824
825 return $OBJ->set_radio($field, $value, $default);
826 }
827}
828
829// ------------------------------------------------------------------------
830
831/**
832 * Form Error
833 *
834 * Returns the error for a specific form field. This is a helper for the
835 * form validation class.
836 *
837 * @access public
838 * @param string
839 * @param string
840 * @param string
841 * @return string
842 */
843if ( ! function_exists('form_error'))
844{
845 function form_error($field = '', $prefix = '', $suffix = '')
846 {
847 if (FALSE === ($OBJ =& _get_validation_object()))
848 {
849 return '';
850 }
851
852 return $OBJ->error($field, $prefix, $suffix);
853 }
854}
855
856// ------------------------------------------------------------------------
857
858/**
859 * Validation Error String
860 *
861 * Returns all the errors associated with a form submission. This is a helper
862 * function for the form validation class.
863 *
864 * @access public
865 * @param string
866 * @param string
867 * @return string
868 */
869if ( ! function_exists('validation_errors'))
870{
871 function validation_errors($prefix = '', $suffix = '')
872 {
873 if (FALSE === ($OBJ =& _get_validation_object()))
874 {
875 return '';
876 }
877
878 return $OBJ->error_string($prefix, $suffix);
879 }
880}
881
882// ------------------------------------------------------------------------
883
884/**
885 * Parse the form attributes
886 *
887 * Helper function used by some of the form helpers
888 *
889 * @access private
890 * @param array
891 * @param array
892 * @return string
893 */
894if ( ! function_exists('_parse_form_attributes'))
895{
896 function _parse_form_attributes($attributes, $default)
897 {
898 if (is_array($attributes))
899 {
900 foreach ($default as $key => $val)
901 {
902 if (isset($attributes[$key]))
903 {
904 $default[$key] = $attributes[$key];
905 unset($attributes[$key]);
906 }
907 }
908
909 if (count($attributes) > 0)
910 {
911 $default = array_merge($default, $attributes);
912 }
913 }
914
915 $att = '';
916
917 foreach ($default as $key => $val)
918 {
919 if ($key == 'value')
920 {
921 $val = form_prep($val);
922 }
923
924 $att .= $key . '="' . $val . '" ';
925 }
926
927 return $att;
928 }
929}
930
931// ------------------------------------------------------------------------
932
933/**
934 * Attributes To String
935 *
936 * Helper function used by some of the form helpers
937 *
938 * @access private
939 * @param mixed
940 * @param bool
941 * @return string
942 */
943if ( ! function_exists('_attributes_to_string'))
944{
945 function _attributes_to_string($attributes, $formtag = FALSE)
946 {
947 if (is_string($attributes) AND strlen($attributes) > 0)
948 {
949 if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
950 {
951 $attributes .= ' method="post"';
952 }
953
954 return ' '.$attributes;
955 }
956
957 if (is_object($attributes) AND count($attributes) > 0)
958 {
959 $attributes = (array)$attributes;
960 }
961
962 if (is_array($attributes) AND count($attributes) > 0)
963 {
964 $atts = '';
965
966 if ( ! isset($attributes['method']) AND $formtag === TRUE)
967 {
968 $atts .= ' method="post"';
969 }
970
971 foreach ($attributes as $key => $val)
972 {
973 $atts .= ' '.$key.'="'.$val.'"';
974 }
975
976 return $atts;
977 }
978 }
979}
980
981// ------------------------------------------------------------------------
982
983/**
984 * Validation Object
985 *
986 * Determines what the form validation class was instantiated as, fetches
987 * the object and returns it.
988 *
989 * @access private
990 * @return mixed
991 */
992if ( ! function_exists('_get_validation_object'))
993{
994 function &_get_validation_object()
995 {
996 $CI =& get_instance();
997
998 // We set this as a variable since we're returning by reference
999 $return = FALSE;
1000
1001 if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
1002 {
1003 return $return;
1004 }
1005
1006 $object = $CI->load->_ci_classes['form_validation'];
1007
1008 if ( ! isset($CI->$object) OR ! is_object($CI->$object))
1009 {
1010 return $return;
1011 }
1012
1013 return $CI->$object;
1014 }
1015}
1016
1017
1018/* End of file form_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +00001019/* Location: ./system/helpers/form_helper.php */