<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// ------------------------------------------------------------------------

/**
* Form Declaration
*
* Creates the opening portion of the form.
*
* @access public
* @param string the URI segments of the form destination
* @param array a key/value pair of attributes
* @param array a key/value pair hidden data
* @return string
*/
if (!function_exists('secure_form_open'))
{
    function secure_form_open($action = '', $attributes = '', $hidden = array())
    {
        $CI =& get_instance();
        
        if ($attributes == '')
        {
            $attributes = 'method="post"';
        }
        
        $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action, TRUE) : $action;
        
        $form = '<form action="'.$action.'"';
        
        $form .= _attributes_to_string($attributes, TRUE);
        
        $form .= '>';
        
        if (is_array($hidden) AND count($hidden) > 0)
        {
            $form .= form_hidden($hidden);
        }
        
        // CSRF
        if ($CI->config->item('csrf_protection') === TRUE)
        {
            $form .= form_hidden($CI->security->csrf_token_name, $CI->security->csrf_hash);
        }
        
        return $form;
    }
}

/* End of file MY_form_helper.php */
/* Location: /application/helpers/MY_form_helper.php */
