-
Notifications
You must be signed in to change notification settings - Fork 4
FormDate
Category:Scripts::Date Category:Scripts::Form
FormDate is a class that creates select and option tags for date and time elements. It relies on the form helpers form_dropdown function.
[h3]Installation[/h3]
Download & unzip [url=http://lab.rotsen.be/php/ci/formdate011.zip]formdate.php[/url] and put it in your apps scripts folder.
[h3]Example[/h3]
Load and instanciate in controller [code]$this->load->script('formdate'); $formdate = new FormDate();[/code]
Set options [code]$formdate->setLocale('nl_BE'); $formdate->year['start'] = 1950; $formdate->year['end'] = 2006; $formdate->month['values'] = 'numbers';[/code]
Make formdate available in the view [code]$data['formdate'] = $formdata; $this->load->view('index', $data);[/code]
Display in view [code] <form> Name <input type="text" />
Day of Birth
<?=$formdate->selectDay()?>
<?=$formdate->selectMonth()?>
<?=$formdate->selectYear()?>
<input type='button' /> </form> [/code]
[h3]Methods and properties[/h3]
[h4]Configuration[/h4]
[code]string $config['prefix'] A prefix that will be added to all select name values[/code]
[h4]formDate()[/h4]
Constructor Initializes the form helper
[h4]setLocale($locale)[/h4]
Set locale for localized time and date strings.
[code]Parameters:
string $locale Locale name (default = 'en_US')
lookup your server supported values with locale -a
shell command[/code]
[h4]selectYear()[/h4]
Returns the years in a select element. You can use the start and end properties or set an offset based around the current year.
[code]Properties: bool $year['descend'] Descend the option list (default = false - ascend) int $year['start'] First year in dropdown int $year['end'] Last year in dropdown int $year['offset'] Offset from current year (default = 3) string $year['name'] Value for select name attribute (default = year) string $year['selected'] Option to select (default = current year) string $year['extra'] Additional attributes for the select element[/code]
[h4]selectMonth()[/h4]
Returns the months in a select element.
[code]Properties: bool $month['descend'] Descend the option list (default = false - ascend) string $month['values'] - 'names' displays the full name (default) - 'numbers' displays month number - 'combined' displays number and full name string $month['name'] Value for select name attribute (default = month) string $month['selected'] Option to select (default = current month) string $month['extra'] Additional attributes for the select element[/code]
[h4]selectDay()[/h4]
Returns the days in a select element.
[code]Properties: bool $day['descend'] Descend the option list (default = false - ascend) string $day['name'] Value for select name attribute (default = day) string $day['selected'] Option to select (default = current day) string $day['extra'] Additional attributes for the select element[/code]
[h4]selectHour()[/h4]
Returns the hours in a select element.
[code]Properties: bool $hour['descend'] Descend the option list (default = false - ascend) bool $hour['leading'] Pad single digits with leading zero (default = true) int $hour['format'] 12 or 24 hour format (default = 12) string $hour['name'] Value for select name attribute (default = hour) string $hour['selected'] Option to select (default = current hour) string $hour['extra'] Additional attributes for the select element[/code]
[h4]selectMinute()[/h4]
Returns the minutes in a select element.
[code]Properties: bool $minute['descend'] Descend the option list (default = false - ascend) bool $minute['leading'] Pad single digits with leading zero (default = true) string $minute['name'] Value for select name attribute (default = minute) string $minute['selected'] Option to select (default = current minute) string $minute['extra'] Additional attributes for the select element[/code]
[h4]selectSecond()[/h4]
Returns the seconds in a select element.
[code]Properties: bool $second['descend'] Descend the option list (default = false - ascend) bool $second['leading'] Pad single digits with leading zero (default = true) string $second['name'] Value for select name attribute (default = second) string $second['selected'] Option to select (default = current second) string $second['extra'] Additional attributes for the select element[/code]
[h4]selectMeridian()[/h4]
Returns AM/PM in a select element.
[code]Properties: bool $meridian['descend'] Descend the option list (default = false - ascend) string $meridian['name'] Value for select name attribute (default = meridian) string $meridian['selected'] Option to select (default = current meridian) string $meridian['extra'] Additional attributes for the select element[/code]