In CodeIgniter, through documentation for your latest version 2.2.0, there is no helper for forms that allows you to generate fields for new types introduced with HTML5.
However, since this is very necessary in the present day, others have gone through this problem and created solutions.
An example can be found in the CodeIgniter forum with the name Extended form helper to support HTML5 form elements (English) whose same goes below:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Common Input Field
*
* @access public
* @param string
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_common'))
{
function form_common($type = 'text', $data = '', $value = '', $extra = '')
{
$defaults = array('type' => $type, 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
return "<input "._parse_form_attributes($data, $defaults).$extra." />";
}
}
/**
* Email Input Field
*
* @access public
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_email'))
{
function form_email($data = '', $value = '', $extra = '')
{
return form_common($type = 'email', $data = '', $value = '', $extra = '');
}
}
/**
* Url Input Field
*
* @access public
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_url'))
{
function form_url($data = '', $value = '', $extra = '')
{
return form_common($type = 'url', $data = '', $value = '', $extra = '');
}
}
/**
* Number Input Field
*
* @access public
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_number'))
{
function form_number($data = '', $value = '', $extra = '')
{
return form_common($type = 'number', $data = '', $value = '', $extra = '');
}
}
/**
* Number Input Field
*
* @access public
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_range'))
{
function form_range($data = '', $value = '', $extra = '')
{
return form_common($type = 'range', $data = '', $value = '', $extra = '');
}
}
/* End of file MY_form_helper.php */
/* Location: ./application/helpers/MY_form_helper.php */
For your particular case in order to create a input[type=data]
you should add to the above referenced file:
/**
* Date Input Field
*
* @access public
* @param mixed
* @param string
* @param string
* @return string
*/
if ( ! function_exists('form_date'))
{
function form_date($data = '', $value = '', $extra = '')
{
return form_common($type = 'date', $data = '', $value = '', $extra = '');
}
}