config->site_url($action);
}
elseif ( ! $action)
{
// If no action is provided then set to the current url
$action = $CI->config->site_url($CI->uri->uri_string());
}
$attributes = _attributes_to_string($attributes);
if (stripos($attributes, 'method=') === FALSE)
{
$attributes .= ' method="post"';
}
if (stripos($attributes, 'accept-charset=') === FALSE)
{
$attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
$form = '
'.$extra;
}
}
// ------------------------------------------------------------------------
if ( ! function_exists('form_prep'))
{
/**
* Form Prep
*
* Formats text so that it can be safely placed in a form field in the event it has HTML tags.
*
* @param string|string[] $str Value to escape
* @param bool $is_textarea Whether we're escaping for a textarea element
* @return string|string[] Escaped values
*/
function form_prep($str = '', $is_textarea = FALSE)
{
if (is_array($str))
{
foreach (array_keys($str) as $key)
{
$str[$key] = form_prep($str[$key], $is_textarea);
}
return $str;
}
if ($is_textarea === TRUE)
{
return str_replace(array('<', '>'), array('<', '>'), stripslashes($str));
}
return str_replace(array("'", '"'), array(''', '"'), stripslashes($str));
}
}
// ------------------------------------------------------------------------
if ( ! function_exists('set_value'))
{
/**
* Form Value
*
* Grabs a value from the POST array for the specified field so you can
* re-populate an input field or textarea. If Form Validation
* is active it retrieves the info from the validation class
*
* @param string $field Field name
* @param string $default Default value
* @param bool $is_textarea Whether the field is a textarea element
* @return string
*/
function set_value($field = '', $default = '', $is_textarea = FALSE)
{
$CI =& get_instance();
$value = (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
? $CI->form_validation->set_value($field, $default)
: $CI->input->post($field, FALSE);
return form_prep($value === NULL ? $default : $value, $is_textarea);
}
}
// ------------------------------------------------------------------------
if ( ! function_exists('set_select'))
{
/**
* Set Select
*
* Let's you set the selected value of a