Date / Time Select Functions

Date / Time Select Functions

datetime_select

Syntax:

$form_options_helper->datetime_select ( $object_name,  $column_name, [ $options ])

Description:
Produces select tags for a year, a month, a day, an hour, and a minute for multi-parameter assignment to an Active Record object.
$object_name references the source of pre-selected data.
$column_name references the column of the pre-selection data.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'start_year' ⇒ $integer
  • 'end_year' ⇒ $integer If end_year < start_year the range will be in descending order; otherwise it will be in ascending order.
  • 'use_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9</option>
  • 'add_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9 - September</option>
  • 'use_short_month' ⇒ false (default) When spelling out month names, the default is to use the full name. This option will use month abbreviations instead.
  • 'minute_step ⇒ 1 (default) This will determine the incremental value of the minutes. The 00 minute will be selected. The $minute variable may be assigned to this option.
  • 'discard_year' ⇒ false (default) If this is set to true, the year will be discarded.
  • 'discard_month' ⇒ false (default) If this is set to true, the month and day will be discarded. Their values will default to 1.
  • 'discard_day' ⇒ false (default) If this is set to true, the day will be discarded. Its value will default to 1.
  • 'order' ⇒ array('year','month','day') (default). The array values may be arranged in another order.
  • 'disabled' ⇒ false (default) If this is set to true, the elements will not be changeable.
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

Examples:
$date_helper→datetime_select(“post”, “written_on”);
$date_helper→datetime_select(“post”, “written_on”, array('start_year' ⇒ 1995));

date_select

Syntax:

$form_options_helper->date_select ( $object_name,  $column_name, [ $options = array()])

Description:
Produces select tags for a year, a month and a day for multi-parameter assignment to an Active Record object.
$object_name references the source of pre-selected data.
$column_name references the column of the pre-selection data.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'start_year' ⇒ $integer
  • 'end_year' ⇒ $integer If end_year < start_year the range will be in descending order; otherwise it will be in ascending order.
  • 'use_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9</option>
  • 'add_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9 - September</option>
  • 'use_short_month' ⇒ false (default) When spelling out month names, the default is to use the full name. This option will use month abbreviations instead.
  • 'discard_year' ⇒ false (default) If this is set to true, the year will be discarded.
  • 'discard_month' ⇒ false (default) If this is set to true, the month and day will be discarded. Their values will default to 1.
  • 'discard_day' ⇒ false (default) If this is set to true, the day will be discarded. Its value will default to 1.
  • 'order' ⇒ array('year','month','day') (default). The array values may be arranged in another order.
  • 'disabled' ⇒ false (default) If this is set to true, the elements will not be changeable.
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

Examples:

$date_helper->date_select("post", "written_on");
$date_helper->date_select("post", "written_on", array('start_year' => 1995));
$date_helper->date_select("post", "written_on", array('start_year' => 1995, 'use_month_numbers' => true, 'discard_day' => true, 'include_blank' => true)));
$date_helper->date_select("post", "written_on", array('order' => array('day', 'month', 'year')));
$date_helper->date_select("user", "birthday", array('order' => array('month', 'day')));
$date_helper->date_select("user","birthday", array('include_blank'=>true));

select_date

Syntax:

$form_options_helper->select_date( [ $date = null], [ $options = array()])

Description:
Returns a set of html select tags: year, month and day pre-selected with the $date or the current date (now). $options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'use_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9</option>
  • 'add_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9 - September</option>
  • 'use_short_month' ⇒ false (default) When spelling out month names, the default is to use the full name. This option will use month abbreviations instead.
  • 'discard_year' ⇒ false (default) If this is set to true, the year will be discarded.
  • 'discard_month' ⇒ false (default) If this is set to true, the month and day will be discarded. Their values will default to 1.
  • 'discard_day' ⇒ false (default) If this is set to true, the day will be discarded. Its value will default to 1.
  • 'order' ⇒ array('year','month','day') (default). The array values may be arranged in another order.
  • 'disabled' ⇒ false (default) If this is set to true, the elements will not be changeable.
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

select_datetime

Syntax:

$form_options_helper->select_datetime( [ $datetime = null], [ $options = array()])

Description:
Returns a set of html select tags: year, month, day, hour and minute pre-selected with the $datetime or the current date/time (now). $options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'use_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9</option>
  • 'add_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9 - September</option>
  • 'use_short_month' ⇒ false (default) When spelling out month names, the default is to use the full name. This option will use month abbreviations instead.
  • 'minute_step ⇒ 1 (default) This will determine the incremental value of the minutes. The 00 minute will be selected. The $minute variable may be assigned to this option.
  • 'discard_year' ⇒ false (default) If this is set to true, the year will be discarded.
  • 'discard_month' ⇒ false (default) If this is set to true, the month and day will be discarded. Their values will default to 1.
  • 'discard_day' ⇒ false (default) If this is set to true, the day will be discarded. Its value will default to 1.
  • 'order' ⇒ array('year','month','day') (default). The array values may be arranged in another order.
  • 'disabled' ⇒ false (default) If this is set to true, the elements will not be changeable.
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

select_day

Syntax:

$form_options_helper->select_day( $date, [ $options ])

Description:
Returns a select tag with options for each of the days 1 through 31 with the day in $date selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt
  • 'field_name' ⇒ 'day' (default) Replace 'day' with $day to get the day numbers from $day = array().

select_hour

Syntax:

$form_options_helper->select_hour( $datetime, [ $options ])

Description:
Returns a select tag with options for each of the hours 0 through 23 with the hour in $datetime selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt
  • 'field_name' ⇒ 'hour' (default) Replace 'hour' with $hour to get the hour numbers from $hour = array().

select_minute

Syntax:

$form_options_helper->select_minute( $datetime, [ $options ])

Description:
Returns a select tag with options for each of the minutes 0 through 59 with the minute in $datetime selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt
  • 'field_name' ⇒ 'minute' (default) Replace 'minute' with $minute to get the hour numbers from $minute = array().
  • 'minute_step ⇒ 1 (default) This will determine the incremental value of the minutes. The 00 minute will be selected. The $minute variable may be assigned to this option.

select_month

Syntax:

$form_options_helper->select_month( [ $date ], [ $options ])

Description:
Returns a select tag with options for each of the months January through December with the month in $date (if any) selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'use_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9</option>
  • 'add_month_numbers' ⇒ false (default) The default is to produce an option string like
    <option value="9">September</option>

    This option produces

    <option value="9">9 - September</option>
  • 'use_short_month' ⇒ false (default) When spelling out month names, the default is to use the full name. This option will use month abbreviations instead.
  • 'field_name' ⇒ 'month' (default) Replace 'month' with $month to get the month numbers from $month = array().
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

Examples:

// Will use keys like "January", "March"
$date_helper->select_month(Ak::getDate()); 
// Will use keys like "1", "3"
$date_helper->select_month(Ak::getDate(), array('use_month_numbers' => true)); 
// Will use keys like "1 - January", "3 - March"
$date_helper->select_month(Ak::getDate(), array('add_month_numbers' => true));

select_second

Syntax:

$form_options_helper->select_second( $datetime, [ $options ])

Description:
Returns a select tag with options for each of the seconds 0 through 59 with the value in $datetime selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt
  • 'field_name ⇒ 'second' (default) Replace 'second' with $second to get the second numbers from $second = array().

select_time

Syntax:

$form_options_helper->select_time( [ $datetime ], [ $options ])

Description:
Returns html select tags for an hour and for a minute. The hour select tag will have options from 0 to 23 with the value in $datetime (if any) selected. The minute select tag will have options from 0 to 59 with the value in $datetime (if any) selected.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

select_year

Syntax:

$form_options_helper->select_year( [ $date ], [ $options ])

Description:
Returns a select tag with options for each of the five years on each side of the year. If $date is provided, it may have one of two types which will determine the selected year:

  • integer – containing a year value
  • date – It's year is selected.

The five year radius can be changed using the start_year and end_year options.
$options = array(). They may be:

  • 'discard_type' ⇒ true (default)
  • 'start_year' ⇒ $integer
  • 'end_year' ⇒ $integer If end_year < start_year the range will be in descending order; otherwise it will be in ascending order.
  • 'field_name ⇒ 'year' (default) Replace 'year' with $year to get the year numbers from $year = array().
  • 'include_blank' ⇒ false (default) Set to true, this causes the first option element to be blank.
  • 'prompt' ⇒ false (default) Set to true, this causes the first option element to be a prompt string. This may be the generic “Please select” or it may be supplied.
    Needed: How to supply a prompt

Examples:

// ascending year values
$date_helper->select_year(Ak::getDate(), array('start_year' => 1992, 'end_year' => 2007));
// descending year values
$date_helper->select_year(Ak::getDate(), array('start_year' => 2005, 'end_year' => 1900));

_select_for

Syntax:

$form_options_helper->_select_for( 
    $select_type,$range,$date_format,$datetime,[ $options ],[ $unit_format_callback ])

Description:
$options is an array.

  • 'discard_type' ⇒ true (default)

$unit_format_callback defaults to '_leading_zero_on_single_digits'.

_select_html

Syntax:

$form_options_helper->_select_html( 
    $type,$options,[ $prefix ],[ $include_blank],[ $discard_type ],[ $disabled])

Description:
$include_blank, $discard_type and $disabled all default to false.

 
helper-select-date-time.txt · Last modified: 2009/09/23 17:36 by jmontoya
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki