Changeset 1465

Show
Ignore:
Timestamp:
12/08/2007 01:25:35 AM (13 months ago)
Author:
Shadowhand
Message:

A couple small Dateselect fixes

Location:
trunk/modules/forge
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/forge/controllers/forge_demo.php

    r1464 r1465  
    2727                $form->checklist('foods')->label('Favorite Foods')->options($foods)->rules('required'); 
    2828                $form->dropdown('state')->label('Home State')->options(locale_US::states())->rules('required'); 
    29                 $form->dateselect('birthday')->label(TRUE)->minutes(5); 
     29                $form->dateselect('birthday')->label(TRUE)->minutes(15)->years(1950, date('Y')); 
    3030                $form->submit('Save'); 
    3131 
  • trunk/modules/forge/libraries/Form_Dateselect.php

    r1464 r1465  
    1414        protected $parts = array 
    1515        ( 
    16                 'month'   => NULL, 
    17                 'day'     => 1, 
    18                 'year'    => NULL, 
     16                'month'   => array(), 
     17                'day'     => array(1), 
     18                'year'    => array(), 
    1919                ' @ ', 
    20                 'hour'    => NULL, 
     20                'hour'    => array(), 
    2121                ':', 
    22                 'minute'  => 5, 
    23                 'am_pm'   => NULL, 
     22                'minute'  => array(5), 
     23                'am_pm'   => array(), 
    2424        ); 
    2525 
     
    3838                { 
    3939                        // Set options for date generation 
    40                         $this->parts[substr($method, 0, -1)] = $args[0]; 
     40                        $this->parts[substr($method, 0, -1)] = $args; 
    4141                        return $this; 
    4242                } 
     
    5757 
    5858                $input = ''; 
    59                 foreach($this->parts as $type => $option) 
     59                foreach($this->parts as $type => $val) 
    6060                { 
    6161                        if (is_int($type)) 
    6262                        { 
    6363                                // Just add the separators 
    64                                 $input .= $option; 
     64                                $input .= $val; 
    6565                                continue; 
    6666                        } 
     
    8383 
    8484                                // Use the date helper to generate the options 
    85                                 $options = ($option === NULL) ? date::$type() : date::$type($option); 
     85                                $options = empty($val) ? date::$type() : call_user_func_array(array('date', $type), $val); 
    8686                        } 
    8787 
     
    101101 
    102102                // Minutes should always be in 5 minute increments 
    103                 $time['minute'] = num::round($time['minute'], $this->parts['minute']); 
     103                $time['minute'] = num::round($time['minute'], current($this->parts['minute'])); 
    104104 
    105105                return $time;