########### Form Helper ########### The Form Helper file contains functions that assist in working with forms. .. contents:: :local: .. raw:: html
Loading this Helper =================== This helper is loaded using the following code:: $this->load->helper('form'); Available Functions =================== The following functions are available: .. function:: form_open([$action = ''[, $attributes = ''[, $hidden = array()]]]) :param string $action: Form action/target URI string :param string $attributes: HTML attributes :param array $hidden: An array of hidden fields' definitions :returns: string Creates an opening form tag with a base URL **built from your config preferences**. It will optionally let you add form attributes and hidden input fields, and will always add the `accept-charset` attribute based on the charset value in your config file. The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable in the event your URLs ever change. Here's a simple example:: echo form_open('email/send'); The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:: **Adding Attributes** Attributes can be added by passing an associative array to the second parameter, like this:: $attributes = array('class' => 'email', 'id' => 'myform'); echo form_open('email/send', $attributes); The above example would create a form similar to this:: **Adding Hidden Input Fields** Hidden fields can be added by passing an associative array to the third parameter, like this:: $hidden = array('username' => 'Joe', 'member_id' => '234'); echo form_open('email/send', '', $hidden); The above example would create a form similar to this:: tag. The only advantage to using this function is it permits you to pass data to it which will be added below the tag. For example:: $string = ''; echo form_close($string); // Would produce: .. function:: form_prep([$str = ''[, $is_textarea = FALSE]]) :param string $str: Value to escape :param bool $is_textarea: Whether we're preparing for