/halogy/helpers/form_helper.php

https://bitbucket.org/haloweb/halogy-1.0/ · PHP · 1025 lines · 565 code · 141 blank · 319 comment · 105 complexity · 20fd7b79617297f05e0bd9e72d53a7c3 MD5 · raw file

  1. <?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 - 2009, 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. * CodeIgniter Form Helpers
  18. *
  19. * @package CodeIgniter
  20. * @subpackage Helpers
  21. * @category Helpers
  22. * @author ExpressionEngine Dev Team
  23. * @link http://codeigniter.com/user_guide/helpers/form_helper.html
  24. */
  25. // ------------------------------------------------------------------------
  26. /**
  27. * Form Declaration
  28. *
  29. * Creates the opening portion of the form.
  30. *
  31. * @access public
  32. * @param string the URI segments of the form destination
  33. * @param array a key/value pair of attributes
  34. * @param array a key/value pair hidden data
  35. * @return string
  36. */
  37. if ( ! function_exists('form_open'))
  38. {
  39. function form_open($action = '', $attributes = '', $hidden = array())
  40. {
  41. $CI =& get_instance();
  42. if ($attributes == '')
  43. {
  44. $attributes = 'method="post"';
  45. }
  46. $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action;
  47. $form = '<form action="'.$action.'"';
  48. $form .= _attributes_to_string($attributes, TRUE);
  49. $form .= '>';
  50. if (is_array($hidden) AND count($hidden) > 0)
  51. {
  52. $form .= form_hidden($hidden);
  53. }
  54. return $form;
  55. }
  56. }
  57. // ------------------------------------------------------------------------
  58. /**
  59. * Form Declaration - Multipart type
  60. *
  61. * Creates the opening portion of the form, but with "multipart/form-data".
  62. *
  63. * @access public
  64. * @param string the URI segments of the form destination
  65. * @param array a key/value pair of attributes
  66. * @param array a key/value pair hidden data
  67. * @return string
  68. */
  69. if ( ! function_exists('form_open_multipart'))
  70. {
  71. function form_open_multipart($action, $attributes = array(), $hidden = array())
  72. {
  73. $attributes['enctype'] = 'multipart/form-data';
  74. return form_open($action, $attributes, $hidden);
  75. }
  76. }
  77. // ------------------------------------------------------------------------
  78. /**
  79. * Hidden Input Field
  80. *
  81. * Generates hidden fields. You can pass a simple key/value string or an associative
  82. * array with multiple values.
  83. *
  84. * @access public
  85. * @param mixed
  86. * @param string
  87. * @return string
  88. */
  89. if ( ! function_exists('form_hidden'))
  90. {
  91. function form_hidden($name, $value = '', $recursing = FALSE)
  92. {
  93. static $form;
  94. if ($recursing === FALSE)
  95. {
  96. $form = "\n";
  97. }
  98. if (is_array($name))
  99. {
  100. foreach ($name as $key => $val)
  101. {
  102. form_hidden($key, $val, TRUE);
  103. }
  104. return $form;
  105. }
  106. if ( ! is_array($value))
  107. {
  108. $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value, $name).'" />'."\n";
  109. }
  110. else
  111. {
  112. foreach ($value as $k => $v)
  113. {
  114. $k = (is_int($k)) ? '' : $k;
  115. form_hidden($name.'['.$k.']', $v, TRUE);
  116. }
  117. }
  118. return $form;
  119. }
  120. }
  121. // ------------------------------------------------------------------------
  122. /**
  123. * Text Input Field
  124. *
  125. * @access public
  126. * @param mixed
  127. * @param string
  128. * @param string
  129. * @return string
  130. */
  131. if ( ! function_exists('form_input'))
  132. {
  133. function form_input($data = '', $value = '', $extra = '')
  134. {
  135. $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
  136. return "<input "._parse_form_attributes($data, $defaults).$extra." />";
  137. }
  138. }
  139. // ------------------------------------------------------------------------
  140. /**
  141. * Password Field
  142. *
  143. * Identical to the input function but adds the "password" type
  144. *
  145. * @access public
  146. * @param mixed
  147. * @param string
  148. * @param string
  149. * @return string
  150. */
  151. if ( ! function_exists('form_password'))
  152. {
  153. function form_password($data = '', $value = '', $extra = '')
  154. {
  155. if ( ! is_array($data))
  156. {
  157. $data = array('name' => $data);
  158. }
  159. $data['type'] = 'password';
  160. return form_input($data, $value, $extra);
  161. }
  162. }
  163. // ------------------------------------------------------------------------
  164. /**
  165. * Upload Field
  166. *
  167. * Identical to the input function but adds the "file" type
  168. *
  169. * @access public
  170. * @param mixed
  171. * @param string
  172. * @param string
  173. * @return string
  174. */
  175. if ( ! function_exists('form_upload'))
  176. {
  177. function form_upload($data = '', $value = '', $extra = '')
  178. {
  179. if ( ! is_array($data))
  180. {
  181. $data = array('name' => $data);
  182. }
  183. $data['type'] = 'file';
  184. return form_input($data, $value, $extra);
  185. }
  186. }
  187. // ------------------------------------------------------------------------
  188. /**
  189. * Textarea field
  190. *
  191. * @access public
  192. * @param mixed
  193. * @param string
  194. * @param string
  195. * @return string
  196. */
  197. if ( ! function_exists('form_textarea'))
  198. {
  199. function form_textarea($data = '', $value = '', $extra = '')
  200. {
  201. $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
  202. if ( ! is_array($data) OR ! isset($data['value']))
  203. {
  204. $val = $value;
  205. }
  206. else
  207. {
  208. $val = $data['value'];
  209. unset($data['value']); // textareas don't use the value attribute
  210. }
  211. $name = (is_array($data)) ? $data['name'] : $data;
  212. return "<textarea "._parse_form_attributes($data, $defaults).$extra.">".form_prep($val, $name)."</textarea>";
  213. }
  214. }
  215. // ------------------------------------------------------------------------
  216. /**
  217. * Multi-select menu
  218. *
  219. * @access public
  220. * @param string
  221. * @param array
  222. * @param mixed
  223. * @param string
  224. * @return type
  225. */
  226. if (! function_exists('form_multiselect'))
  227. {
  228. function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '')
  229. {
  230. if ( ! strpos($extra, 'multiple'))
  231. {
  232. $extra .= ' multiple="multiple"';
  233. }
  234. return form_dropdown($name, $options, $selected, $extra);
  235. }
  236. }
  237. // --------------------------------------------------------------------
  238. /**
  239. * Drop-down Menu
  240. *
  241. * @access public
  242. * @param string
  243. * @param array
  244. * @param string
  245. * @param string
  246. * @return string
  247. */
  248. if ( ! function_exists('form_dropdown'))
  249. {
  250. function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
  251. {
  252. if ( ! is_array($selected))
  253. {
  254. $selected = array($selected);
  255. }
  256. // If no selected state was submitted we will attempt to set it automatically
  257. if (count($selected) === 0)
  258. {
  259. // If the form name appears in the $_POST array we have a winner!
  260. if (isset($_POST[$name]))
  261. {
  262. $selected = array($_POST[$name]);
  263. }
  264. }
  265. if ($extra != '') $extra = ' '.$extra;
  266. $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
  267. $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
  268. foreach ($options as $key => $val)
  269. {
  270. $key = (string) $key;
  271. if (is_array($val))
  272. {
  273. $form .= '<optgroup label="'.$key.'">'."\n";
  274. foreach ($val as $optgroup_key => $optgroup_val)
  275. {
  276. $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
  277. $form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
  278. }
  279. $form .= '</optgroup>'."\n";
  280. }
  281. else
  282. {
  283. $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
  284. $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
  285. }
  286. }
  287. $form .= '</select>';
  288. return $form;
  289. }
  290. }
  291. // ------------------------------------------------------------------------
  292. /**
  293. * Checkbox Field
  294. *
  295. * @access public
  296. * @param mixed
  297. * @param string
  298. * @param bool
  299. * @param string
  300. * @return string
  301. */
  302. if ( ! function_exists('form_checkbox'))
  303. {
  304. function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
  305. {
  306. $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
  307. if (is_array($data) AND array_key_exists('checked', $data))
  308. {
  309. $checked = $data['checked'];
  310. if ($checked == FALSE)
  311. {
  312. unset($data['checked']);
  313. }
  314. else
  315. {
  316. $data['checked'] = 'checked';
  317. }
  318. }
  319. if ($checked == TRUE)
  320. {
  321. $defaults['checked'] = 'checked';
  322. }
  323. else
  324. {
  325. unset($defaults['checked']);
  326. }
  327. return "<input "._parse_form_attributes($data, $defaults).$extra." />";
  328. }
  329. }
  330. // ------------------------------------------------------------------------
  331. /**
  332. * Radio Button
  333. *
  334. * @access public
  335. * @param mixed
  336. * @param string
  337. * @param bool
  338. * @param string
  339. * @return string
  340. */
  341. if ( ! function_exists('form_radio'))
  342. {
  343. function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
  344. {
  345. if ( ! is_array($data))
  346. {
  347. $data = array('name' => $data);
  348. }
  349. $data['type'] = 'radio';
  350. return form_checkbox($data, $value, $checked, $extra);
  351. }
  352. }
  353. // ------------------------------------------------------------------------
  354. /**
  355. * Submit Button
  356. *
  357. * @access public
  358. * @param mixed
  359. * @param string
  360. * @param string
  361. * @return string
  362. */
  363. if ( ! function_exists('form_submit'))
  364. {
  365. function form_submit($data = '', $value = '', $extra = '')
  366. {
  367. $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
  368. return "<input "._parse_form_attributes($data, $defaults).$extra." />";
  369. }
  370. }
  371. // ------------------------------------------------------------------------
  372. /**
  373. * Reset Button
  374. *
  375. * @access public
  376. * @param mixed
  377. * @param string
  378. * @param string
  379. * @return string
  380. */
  381. if ( ! function_exists('form_reset'))
  382. {
  383. function form_reset($data = '', $value = '', $extra = '')
  384. {
  385. $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
  386. return "<input "._parse_form_attributes($data, $defaults).$extra." />";
  387. }
  388. }
  389. // ------------------------------------------------------------------------
  390. /**
  391. * Form Button
  392. *
  393. * @access public
  394. * @param mixed
  395. * @param string
  396. * @param string
  397. * @return string
  398. */
  399. if ( ! function_exists('form_button'))
  400. {
  401. function form_button($data = '', $content = '', $extra = '')
  402. {
  403. $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
  404. if ( is_array($data) AND isset($data['content']))
  405. {
  406. $content = $data['content'];
  407. unset($data['content']); // content is not an attribute
  408. }
  409. return "<button "._parse_form_attributes($data, $defaults).$extra.">".$content."</button>";
  410. }
  411. }
  412. // ------------------------------------------------------------------------
  413. /**
  414. * Form Label Tag
  415. *
  416. * @access public
  417. * @param string The text to appear onscreen
  418. * @param string The id the label applies to
  419. * @param string Additional attributes
  420. * @return string
  421. */
  422. if ( ! function_exists('form_label'))
  423. {
  424. function form_label($label_text = '', $id = '', $attributes = array())
  425. {
  426. $label = '<label';
  427. if ($id != '')
  428. {
  429. $label .= " for=\"$id\"";
  430. }
  431. if (is_array($attributes) AND count($attributes) > 0)
  432. {
  433. foreach ($attributes as $key => $val)
  434. {
  435. $label .= ' '.$key.'="'.$val.'"';
  436. }
  437. }
  438. $label .= ">$label_text</label>";
  439. return $label;
  440. }
  441. }
  442. // ------------------------------------------------------------------------
  443. /**
  444. * Fieldset Tag
  445. *
  446. * Used to produce <fieldset><legend>text</legend>. To close fieldset
  447. * use form_fieldset_close()
  448. *
  449. * @access public
  450. * @param string The legend text
  451. * @param string Additional attributes
  452. * @return string
  453. */
  454. if ( ! function_exists('form_fieldset'))
  455. {
  456. function form_fieldset($legend_text = '', $attributes = array())
  457. {
  458. $fieldset = "<fieldset";
  459. $fieldset .= _attributes_to_string($attributes, FALSE);
  460. $fieldset .= ">\n";
  461. if ($legend_text != '')
  462. {
  463. $fieldset .= "<legend>$legend_text</legend>\n";
  464. }
  465. return $fieldset;
  466. }
  467. }
  468. // ------------------------------------------------------------------------
  469. /**
  470. * Fieldset Close Tag
  471. *
  472. * @access public
  473. * @param string
  474. * @return string
  475. */
  476. if ( ! function_exists('form_fieldset_close'))
  477. {
  478. function form_fieldset_close($extra = '')
  479. {
  480. return "</fieldset>".$extra;
  481. }
  482. }
  483. // ------------------------------------------------------------------------
  484. /**
  485. * Form Close Tag
  486. *
  487. * @access public
  488. * @param string
  489. * @return string
  490. */
  491. if ( ! function_exists('form_close'))
  492. {
  493. function form_close($extra = '')
  494. {
  495. return "</form>".$extra;
  496. }
  497. }
  498. // ------------------------------------------------------------------------
  499. /**
  500. * Form Prep
  501. *
  502. * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
  503. *
  504. * @access public
  505. * @param string
  506. * @return string
  507. */
  508. if ( ! function_exists('form_prep'))
  509. {
  510. function form_prep($str = '', $field_name = '')
  511. {
  512. static $prepped_fields = array();
  513. // if the field name is an array we do this recursively
  514. if (is_array($str))
  515. {
  516. foreach ($str as $key => $val)
  517. {
  518. $str[$key] = form_prep($val);
  519. }
  520. return $str;
  521. }
  522. if ($str === '')
  523. {
  524. return '';
  525. }
  526. // we've already prepped a field with this name
  527. // @todo need to figure out a way to namespace this so
  528. // that we know the *exact* field and not just one with
  529. // the same name
  530. if (isset($prepped_fields[$field_name]))
  531. {
  532. return $str;
  533. }
  534. $str = htmlspecialchars($str);
  535. // In case htmlspecialchars misses these.
  536. $str = str_replace(array("'", '"'), array("&#39;", "&quot;"), $str);
  537. if ($field_name != '')
  538. {
  539. $prepped_fields[$field_name] = $str;
  540. }
  541. return $str;
  542. }
  543. }
  544. // ------------------------------------------------------------------------
  545. /**
  546. * Form Value
  547. *
  548. * Grabs a value from the POST array for the specified field so you can
  549. * re-populate an input field or textarea. If Form Validation
  550. * is active it retrieves the info from the validation class
  551. *
  552. * @access public
  553. * @param string
  554. * @return mixed
  555. */
  556. if ( ! function_exists('set_value'))
  557. {
  558. function set_value($field = '', $default = '')
  559. {
  560. if (FALSE === ($OBJ =& _get_validation_object()))
  561. {
  562. if ( ! isset($_POST[$field]))
  563. {
  564. return $default;
  565. }
  566. return form_prep($_POST[$field], $field);
  567. }
  568. return form_prep($OBJ->set_value($field, $default), $field);
  569. }
  570. }
  571. // ------------------------------------------------------------------------
  572. /**
  573. * Set Select
  574. *
  575. * Let's you set the selected value of a <select> menu via data in the POST array.
  576. * If Form Validation is active it retrieves the info from the validation class
  577. *
  578. * @access public
  579. * @param string
  580. * @param string
  581. * @param bool
  582. * @return string
  583. */
  584. if ( ! function_exists('set_select'))
  585. {
  586. function set_select($field = '', $value = '', $default = FALSE)
  587. {
  588. $OBJ =& _get_validation_object();
  589. if ($OBJ === FALSE)
  590. {
  591. if ( ! isset($_POST[$field]))
  592. {
  593. if (count($_POST) === 0 AND $default == TRUE)
  594. {
  595. return ' selected="selected"';
  596. }
  597. return '';
  598. }
  599. $field = $_POST[$field];
  600. if (is_array($field))
  601. {
  602. if ( ! in_array($value, $field))
  603. {
  604. return '';
  605. }
  606. }
  607. else
  608. {
  609. if (($field == '' OR $value == '') OR ($field != $value))
  610. {
  611. return '';
  612. }
  613. }
  614. return ' selected="selected"';
  615. }
  616. return $OBJ->set_select($field, $value, $default);
  617. }
  618. }
  619. // ------------------------------------------------------------------------
  620. /**
  621. * Set Checkbox
  622. *
  623. * Let's you set the selected value of a checkbox via the value in the POST array.
  624. * If Form Validation is active it retrieves the info from the validation class
  625. *
  626. * @access public
  627. * @param string
  628. * @param string
  629. * @param bool
  630. * @return string
  631. */
  632. if ( ! function_exists('set_checkbox'))
  633. {
  634. function set_checkbox($field = '', $value = '', $default = FALSE)
  635. {
  636. $OBJ =& _get_validation_object();
  637. if ($OBJ === FALSE)
  638. {
  639. if ( ! isset($_POST[$field]))
  640. {
  641. if (count($_POST) === 0 AND $default == TRUE)
  642. {
  643. return ' checked="checked"';
  644. }
  645. return '';
  646. }
  647. $field = $_POST[$field];
  648. if (is_array($field))
  649. {
  650. if ( ! in_array($value, $field))
  651. {
  652. return '';
  653. }
  654. }
  655. else
  656. {
  657. if (($field == '' OR $value == '') OR ($field != $value))
  658. {
  659. return '';
  660. }
  661. }
  662. return ' checked="checked"';
  663. }
  664. return $OBJ->set_checkbox($field, $value, $default);
  665. }
  666. }
  667. // ------------------------------------------------------------------------
  668. /**
  669. * Set Radio
  670. *
  671. * Let's you set the selected value of a radio field via info in the POST array.
  672. * If Form Validation is active it retrieves the info from the validation class
  673. *
  674. * @access public
  675. * @param string
  676. * @param string
  677. * @param bool
  678. * @return string
  679. */
  680. if ( ! function_exists('set_radio'))
  681. {
  682. function set_radio($field = '', $value = '', $default = FALSE)
  683. {
  684. $OBJ =& _get_validation_object();
  685. if ($OBJ === FALSE)
  686. {
  687. if ( ! isset($_POST[$field]))
  688. {
  689. if (count($_POST) === 0 AND $default == TRUE)
  690. {
  691. return ' checked="checked"';
  692. }
  693. return '';
  694. }
  695. $field = $_POST[$field];
  696. if (is_array($field))
  697. {
  698. if ( ! in_array($value, $field))
  699. {
  700. return '';
  701. }
  702. }
  703. else
  704. {
  705. if (($field == '' OR $value == '') OR ($field != $value))
  706. {
  707. return '';
  708. }
  709. }
  710. return ' checked="checked"';
  711. }
  712. return $OBJ->set_radio($field, $value, $default);
  713. }
  714. }
  715. // ------------------------------------------------------------------------
  716. /**
  717. * Form Error
  718. *
  719. * Returns the error for a specific form field. This is a helper for the
  720. * form validation class.
  721. *
  722. * @access public
  723. * @param string
  724. * @param string
  725. * @param string
  726. * @return string
  727. */
  728. if ( ! function_exists('form_error'))
  729. {
  730. function form_error($field = '', $prefix = '', $suffix = '')
  731. {
  732. if (FALSE === ($OBJ =& _get_validation_object()))
  733. {
  734. return '';
  735. }
  736. return $OBJ->error($field, $prefix, $suffix);
  737. }
  738. }
  739. // ------------------------------------------------------------------------
  740. /**
  741. * Validation Error String
  742. *
  743. * Returns all the errors associated with a form submission. This is a helper
  744. * function for the form validation class.
  745. *
  746. * @access public
  747. * @param string
  748. * @param string
  749. * @return string
  750. */
  751. if ( ! function_exists('validation_errors'))
  752. {
  753. function validation_errors($prefix = '', $suffix = '')
  754. {
  755. if (FALSE === ($OBJ =& _get_validation_object()))
  756. {
  757. return '';
  758. }
  759. return $OBJ->error_string($prefix, $suffix);
  760. }
  761. }
  762. // ------------------------------------------------------------------------
  763. /**
  764. * Parse the form attributes
  765. *
  766. * Helper function used by some of the form helpers
  767. *
  768. * @access private
  769. * @param array
  770. * @param array
  771. * @return string
  772. */
  773. if ( ! function_exists('_parse_form_attributes'))
  774. {
  775. function _parse_form_attributes($attributes, $default)
  776. {
  777. if (is_array($attributes))
  778. {
  779. foreach ($default as $key => $val)
  780. {
  781. if (isset($attributes[$key]))
  782. {
  783. $default[$key] = $attributes[$key];
  784. unset($attributes[$key]);
  785. }
  786. }
  787. if (count($attributes) > 0)
  788. {
  789. $default = array_merge($default, $attributes);
  790. }
  791. }
  792. $att = '';
  793. foreach ($default as $key => $val)
  794. {
  795. if ($key == 'value')
  796. {
  797. $val = form_prep($val, $default['name']);
  798. }
  799. $att .= $key . '="' . $val . '" ';
  800. }
  801. return $att;
  802. }
  803. }
  804. // ------------------------------------------------------------------------
  805. /**
  806. * Attributes To String
  807. *
  808. * Helper function used by some of the form helpers
  809. *
  810. * @access private
  811. * @param mixed
  812. * @param bool
  813. * @return string
  814. */
  815. if ( ! function_exists('_attributes_to_string'))
  816. {
  817. function _attributes_to_string($attributes, $formtag = FALSE)
  818. {
  819. if (is_string($attributes) AND strlen($attributes) > 0)
  820. {
  821. if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
  822. {
  823. $attributes .= ' method="post"';
  824. }
  825. return ' '.$attributes;
  826. }
  827. if (is_object($attributes) AND count($attributes) > 0)
  828. {
  829. $attributes = (array)$attributes;
  830. }
  831. if (is_array($attributes) AND count($attributes) > 0)
  832. {
  833. $atts = '';
  834. if ( ! isset($attributes['method']) AND $formtag === TRUE)
  835. {
  836. $atts .= ' method="post"';
  837. }
  838. foreach ($attributes as $key => $val)
  839. {
  840. $atts .= ' '.$key.'="'.$val.'"';
  841. }
  842. return $atts;
  843. }
  844. }
  845. }
  846. // ------------------------------------------------------------------------
  847. /**
  848. * Validation Object
  849. *
  850. * Determines what the form validation class was instantiated as, fetches
  851. * the object and returns it.
  852. *
  853. * @access private
  854. * @return mixed
  855. */
  856. if ( ! function_exists('_get_validation_object'))
  857. {
  858. function &_get_validation_object()
  859. {
  860. $CI =& get_instance();
  861. // We set this as a variable since we're returning by reference
  862. $return = FALSE;
  863. if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
  864. {
  865. return $return;
  866. }
  867. $object = $CI->load->_ci_classes['form_validation'];
  868. if ( ! isset($CI->$object) OR ! is_object($CI->$object))
  869. {
  870. return $return;
  871. }
  872. return $CI->$object;
  873. }
  874. }
  875. /* End of file form_helper.php */
  876. /* Location: ./system/helpers/form_helper.php */