blob: 0173340c5b36f39b3752b9424fc0ea403c98d64d [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/**
250 * Drop-down Menu
251 *
252 * @access public
253 * @param string
254 * @param array
255 * @param string
256 * @param string
257 * @return string
258 */
259if ( ! function_exists('form_dropdown'))
260{
261 function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
262 {
263 if ( ! is_array($selected))
264 {
265 $selected = array($selected);
266 }
267
268 // If no selected state was submitted we will attempt to set it automatically
269 if (count($selected) === 0)
270 {
271 // If the form name appears in the $_POST array we have a winner!
272 if (isset($_POST[$name]))
273 {
274 $selected = array($_POST[$name]);
275 }
276 }
277
278 if ($extra != '') $extra = ' '.$extra;
279
280 $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
281
282 $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
Robin Sowell57fe4102009-03-26 18:58:46 +0000283
Derek Allard2067d1a2008-11-13 22:59:24 +0000284 foreach ($options as $key => $val)
285 {
286 $key = (string) $key;
Derek Allard2067d1a2008-11-13 22:59:24 +0000287
Derek Allard78a5fc92009-02-05 16:34:35 +0000288 if (is_array($val))
289 {
290 $form .= '<optgroup label="'.$key.'">'."\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000291
Derek Allard78a5fc92009-02-05 16:34:35 +0000292 foreach ($val as $optgroup_key => $optgroup_val)
293 {
Derek Allard86a840c2009-02-05 17:31:58 +0000294 $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
Derek Allard78a5fc92009-02-05 16:34:35 +0000295
296 $form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
297 }
298
299 $form .= '</optgroup>'."\n";
300 }
301 else
302 {
303 $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
304
305 $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
306 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000307 }
308
309 $form .= '</select>';
310
311 return $form;
312 }
313}
314
315// ------------------------------------------------------------------------
316
317/**
318 * Checkbox Field
319 *
320 * @access public
321 * @param mixed
322 * @param string
323 * @param bool
324 * @param string
325 * @return string
326 */
327if ( ! function_exists('form_checkbox'))
328{
329 function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
330 {
331 $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
332
333 if (is_array($data) AND array_key_exists('checked', $data))
334 {
335 $checked = $data['checked'];
336
337 if ($checked == FALSE)
338 {
339 unset($data['checked']);
340 }
341 else
342 {
343 $data['checked'] = 'checked';
344 }
345 }
346
347 if ($checked == TRUE)
348 {
349 $defaults['checked'] = 'checked';
350 }
351 else
352 {
353 unset($defaults['checked']);
354 }
355
356 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
357 }
358}
359
360// ------------------------------------------------------------------------
361
362/**
363 * Radio Button
364 *
365 * @access public
366 * @param mixed
367 * @param string
368 * @param bool
369 * @param string
370 * @return string
371 */
372if ( ! function_exists('form_radio'))
373{
374 function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
375 {
376 if ( ! is_array($data))
377 {
378 $data = array('name' => $data);
379 }
380
381 $data['type'] = 'radio';
382 return form_checkbox($data, $value, $checked, $extra);
383 }
384}
385
386// ------------------------------------------------------------------------
387
388/**
389 * Submit Button
390 *
391 * @access public
392 * @param mixed
393 * @param string
394 * @param string
395 * @return string
396 */
397if ( ! function_exists('form_submit'))
398{
399 function form_submit($data = '', $value = '', $extra = '')
400 {
401 $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
402
403 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
404 }
405}
406
407// ------------------------------------------------------------------------
408
409/**
410 * Reset Button
411 *
412 * @access public
413 * @param mixed
414 * @param string
415 * @param string
416 * @return string
417 */
418if ( ! function_exists('form_reset'))
419{
420 function form_reset($data = '', $value = '', $extra = '')
421 {
422 $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
423
424 return "<input "._parse_form_attributes($data, $defaults).$extra." />";
425 }
426}
427
428// ------------------------------------------------------------------------
429
430/**
431 * Form Button
432 *
433 * @access public
434 * @param mixed
435 * @param string
436 * @param string
437 * @return string
438 */
439if ( ! function_exists('form_button'))
440{
441 function form_button($data = '', $content = '', $extra = '')
442 {
Derek Allard904094a2009-02-10 14:00:34 +0000443 $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
Derek Allard2067d1a2008-11-13 22:59:24 +0000444
445 if ( is_array($data) AND isset($data['content']))
446 {
447 $content = $data['content'];
448 unset($data['content']); // content is not an attribute
449 }
450
451 return "<button "._parse_form_attributes($data, $defaults).$extra.">".$content."</button>";
452 }
453}
454
455// ------------------------------------------------------------------------
456
457/**
458 * Form Label Tag
459 *
460 * @access public
461 * @param string The text to appear onscreen
462 * @param string The id the label applies to
463 * @param string Additional attributes
464 * @return string
465 */
466if ( ! function_exists('form_label'))
467{
468 function form_label($label_text = '', $id = '', $attributes = array())
469 {
470
471 $label = '<label';
472
473 if ($id != '')
474 {
475 $label .= " for=\"$id\"";
476 }
477
478 if (is_array($attributes) AND count($attributes) > 0)
479 {
480 foreach ($attributes as $key => $val)
481 {
482 $label .= ' '.$key.'="'.$val.'"';
483 }
484 }
485
486 $label .= ">$label_text</label>";
487
488 return $label;
489 }
490}
491
492// ------------------------------------------------------------------------
493/**
494 * Fieldset Tag
495 *
496 * Used to produce <fieldset><legend>text</legend>. To close fieldset
497 * use form_fieldset_close()
498 *
499 * @access public
500 * @param string The legend text
501 * @param string Additional attributes
502 * @return string
503 */
504if ( ! function_exists('form_fieldset'))
505{
506 function form_fieldset($legend_text = '', $attributes = array())
507 {
508 $fieldset = "<fieldset";
509
510 $fieldset .= _attributes_to_string($attributes, FALSE);
511
512 $fieldset .= ">\n";
513
514 if ($legend_text != '')
515 {
516 $fieldset .= "<legend>$legend_text</legend>\n";
517 }
518
519 return $fieldset;
520 }
521}
522
523// ------------------------------------------------------------------------
524
525/**
526 * Fieldset Close Tag
527 *
528 * @access public
529 * @param string
530 * @return string
531 */
532if ( ! function_exists('form_fieldset_close'))
533{
534 function form_fieldset_close($extra = '')
535 {
536 return "</fieldset>".$extra;
537 }
538}
539
540// ------------------------------------------------------------------------
541
542/**
543 * Form Close Tag
544 *
545 * @access public
546 * @param string
547 * @return string
548 */
549if ( ! function_exists('form_close'))
550{
551 function form_close($extra = '')
552 {
553 return "</form>".$extra;
554 }
555}
556
557// ------------------------------------------------------------------------
558
559/**
560 * Form Prep
561 *
562 * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
563 *
564 * @access public
565 * @param string
566 * @return string
567 */
568if ( ! function_exists('form_prep'))
569{
570 function form_prep($str = '')
571 {
572 // if the field name is an array we do this recursively
573 if (is_array($str))
574 {
575 foreach ($str as $key => $val)
576 {
577 $str[$key] = form_prep($val);
578 }
579
580 return $str;
581 }
582
583 if ($str === '')
584 {
585 return '';
586 }
587
588 $temp = '__TEMP_AMPERSANDS__';
589
590 // Replace entities to temporary markers so that
591 // htmlspecialchars won't mess them up
592 $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
593 $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
594
595 $str = htmlspecialchars($str);
596
597 // In case htmlspecialchars misses these.
598 $str = str_replace(array("'", '"'), array("&#39;", "&quot;"), $str);
599
600 // Decode the temp markers back to entities
601 $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
602 $str = preg_replace("/$temp(\w+);/","&\\1;",$str);
603
604 return $str;
605 }
606}
607
608// ------------------------------------------------------------------------
609
610/**
611 * Form Value
612 *
613 * Grabs a value from the POST array for the specified field so you can
614 * re-populate an input field or textarea. If Form Validation
615 * is active it retrieves the info from the validation class
616 *
617 * @access public
618 * @param string
619 * @return mixed
620 */
621if ( ! function_exists('set_value'))
622{
623 function set_value($field = '', $default = '')
624 {
625 if (FALSE === ($OBJ =& _get_validation_object()))
626 {
627 if ( ! isset($_POST[$field]))
628 {
629 return $default;
630 }
631
632 return form_prep($_POST[$field]);
633 }
634
635 return form_prep($OBJ->set_value($field, $default));
636 }
637}
638
639// ------------------------------------------------------------------------
640
641/**
642 * Set Select
643 *
644 * Let's you set the selected value of a <select> menu via data in the POST array.
645 * If Form Validation is active it retrieves the info from the validation class
646 *
647 * @access public
648 * @param string
649 * @param string
650 * @param bool
651 * @return string
652 */
653if ( ! function_exists('set_select'))
654{
655 function set_select($field = '', $value = '', $default = FALSE)
656 {
657 $OBJ =& _get_validation_object();
658
659 if ($OBJ === FALSE)
660 {
661 if ( ! isset($_POST[$field]))
662 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000663 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000664 {
665 return ' selected="selected"';
666 }
667 return '';
668 }
669
670 $field = $_POST[$field];
671
672 if (is_array($field))
673 {
674 if ( ! in_array($value, $field))
675 {
676 return '';
677 }
678 }
679 else
680 {
681 if (($field == '' OR $value == '') OR ($field != $value))
682 {
683 return '';
684 }
685 }
686
687 return ' selected="selected"';
688 }
689
690 return $OBJ->set_select($field, $value, $default);
691 }
692}
693
694// ------------------------------------------------------------------------
695
696/**
697 * Set Checkbox
698 *
699 * Let's you set the selected value of a checkbox via the value in the POST array.
700 * If Form Validation is active it retrieves the info from the validation class
701 *
702 * @access public
703 * @param string
704 * @param string
705 * @param bool
706 * @return string
707 */
708if ( ! function_exists('set_checkbox'))
709{
710 function set_checkbox($field = '', $value = '', $default = FALSE)
711 {
712 $OBJ =& _get_validation_object();
713
714 if ($OBJ === FALSE)
715 {
716 if ( ! isset($_POST[$field]))
717 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000718 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000719 {
720 return ' checked="checked"';
721 }
722 return '';
723 }
724
725 $field = $_POST[$field];
726
727 if (is_array($field))
728 {
729 if ( ! in_array($value, $field))
730 {
731 return '';
732 }
733 }
734 else
735 {
736 if (($field == '' OR $value == '') OR ($field != $value))
737 {
738 return '';
739 }
740 }
741
742 return ' checked="checked"';
743 }
744
745 return $OBJ->set_checkbox($field, $value, $default);
746 }
747}
748
749// ------------------------------------------------------------------------
750
751/**
752 * Set Radio
753 *
754 * Let's you set the selected value of a radio field via info in the POST array.
755 * If Form Validation is active it retrieves the info from the validation class
756 *
757 * @access public
758 * @param string
759 * @param string
760 * @param bool
761 * @return string
762 */
763if ( ! function_exists('set_radio'))
764{
765 function set_radio($field = '', $value = '', $default = FALSE)
766 {
767 $OBJ =& _get_validation_object();
768
769 if ($OBJ === FALSE)
770 {
771 if ( ! isset($_POST[$field]))
772 {
Rick Ellis28e5c8f2009-03-09 22:36:48 +0000773 if (count($_POST) === 0 AND $default == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000774 {
775 return ' checked="checked"';
776 }
777 return '';
778 }
779
780 $field = $_POST[$field];
781
782 if (is_array($field))
783 {
784 if ( ! in_array($value, $field))
785 {
786 return '';
787 }
788 }
789 else
790 {
791 if (($field == '' OR $value == '') OR ($field != $value))
792 {
793 return '';
794 }
795 }
796
797 return ' checked="checked"';
798 }
799
800 return $OBJ->set_radio($field, $value, $default);
801 }
802}
803
804// ------------------------------------------------------------------------
805
806/**
807 * Form Error
808 *
809 * Returns the error for a specific form field. This is a helper for the
810 * form validation class.
811 *
812 * @access public
813 * @param string
814 * @param string
815 * @param string
816 * @return string
817 */
818if ( ! function_exists('form_error'))
819{
820 function form_error($field = '', $prefix = '', $suffix = '')
821 {
822 if (FALSE === ($OBJ =& _get_validation_object()))
823 {
824 return '';
825 }
826
827 return $OBJ->error($field, $prefix, $suffix);
828 }
829}
830
831// ------------------------------------------------------------------------
832
833/**
834 * Validation Error String
835 *
836 * Returns all the errors associated with a form submission. This is a helper
837 * function for the form validation class.
838 *
839 * @access public
840 * @param string
841 * @param string
842 * @return string
843 */
844if ( ! function_exists('validation_errors'))
845{
846 function validation_errors($prefix = '', $suffix = '')
847 {
848 if (FALSE === ($OBJ =& _get_validation_object()))
849 {
850 return '';
851 }
852
853 return $OBJ->error_string($prefix, $suffix);
854 }
855}
856
857// ------------------------------------------------------------------------
858
859/**
860 * Parse the form attributes
861 *
862 * Helper function used by some of the form helpers
863 *
864 * @access private
865 * @param array
866 * @param array
867 * @return string
868 */
869if ( ! function_exists('_parse_form_attributes'))
870{
871 function _parse_form_attributes($attributes, $default)
872 {
873 if (is_array($attributes))
874 {
875 foreach ($default as $key => $val)
876 {
877 if (isset($attributes[$key]))
878 {
879 $default[$key] = $attributes[$key];
880 unset($attributes[$key]);
881 }
882 }
883
884 if (count($attributes) > 0)
885 {
886 $default = array_merge($default, $attributes);
887 }
888 }
889
890 $att = '';
891
892 foreach ($default as $key => $val)
893 {
894 if ($key == 'value')
895 {
896 $val = form_prep($val);
897 }
898
899 $att .= $key . '="' . $val . '" ';
900 }
901
902 return $att;
903 }
904}
905
906// ------------------------------------------------------------------------
907
908/**
909 * Attributes To String
910 *
911 * Helper function used by some of the form helpers
912 *
913 * @access private
914 * @param mixed
915 * @param bool
916 * @return string
917 */
918if ( ! function_exists('_attributes_to_string'))
919{
920 function _attributes_to_string($attributes, $formtag = FALSE)
921 {
922 if (is_string($attributes) AND strlen($attributes) > 0)
923 {
924 if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
925 {
926 $attributes .= ' method="post"';
927 }
928
929 return ' '.$attributes;
930 }
931
932 if (is_object($attributes) AND count($attributes) > 0)
933 {
934 $attributes = (array)$attributes;
935 }
936
937 if (is_array($attributes) AND count($attributes) > 0)
938 {
939 $atts = '';
940
941 if ( ! isset($attributes['method']) AND $formtag === TRUE)
942 {
943 $atts .= ' method="post"';
944 }
945
946 foreach ($attributes as $key => $val)
947 {
948 $atts .= ' '.$key.'="'.$val.'"';
949 }
950
951 return $atts;
952 }
953 }
954}
955
956// ------------------------------------------------------------------------
957
958/**
959 * Validation Object
960 *
961 * Determines what the form validation class was instantiated as, fetches
962 * the object and returns it.
963 *
964 * @access private
965 * @return mixed
966 */
967if ( ! function_exists('_get_validation_object'))
968{
969 function &_get_validation_object()
970 {
971 $CI =& get_instance();
972
973 // We set this as a variable since we're returning by reference
974 $return = FALSE;
975
976 if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
977 {
978 return $return;
979 }
980
981 $object = $CI->load->_ci_classes['form_validation'];
982
983 if ( ! isset($CI->$object) OR ! is_object($CI->$object))
984 {
985 return $return;
986 }
987
988 return $CI->$object;
989 }
990}
991
992
993/* End of file form_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +0000994/* Location: ./system/helpers/form_helper.php */