Changeset 24605
- Timestamp:
- 11/30/09 22:20:19 (3 years ago)
- Files:
-
- branches/1.3/lib/widget/sfWidgetFormDate.class.php (modified) (2 diffs)
- branches/1.4/lib/widget/sfWidgetFormDate.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.3/lib/widget/sfWidgetFormDate.class.php
r16259 r24605 4 4 * This file is part of the symfony package. 5 5 * (c) Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 83 83 $emptyValues = $this->getOption('empty_values'); 84 84 85 // days86 $ widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')), array_merge($this->attributes, $attributes));87 $date['% day%'] = $widget->render($name.'[day]', $value['day']);85 $date['%day%'] = $this->renderDayWidget($name.'[day]', $value['day'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')), array_merge($this->attributes, $attributes)); 86 $date['%month%'] = $this->renderMonthWidget($name.'[month]', $value['month'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')), array_merge($this->attributes, $attributes)); 87 $date['%year%'] = $this->renderYearWidget($name.'[year]', $value['year'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), array_merge($this->attributes, $attributes)); 88 88 89 // months90 $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')), array_merge($this->attributes, $attributes));91 $date['%month%'] = $widget->render($name.'[month]', $value['month']);92 93 // years94 $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), array_merge($this->attributes, $attributes));95 $date['%year%'] = $widget->render($name.'[year]', $value['year']);96 89 97 90 return strtr($this->getOption('format'), $date); 98 91 } 92 93 /** 94 * @param string $name 95 * @param string $value 96 * @param array $options 97 * @param array $attributes 98 * @return string rendered widget 99 */ 100 protected function renderDayWidget($name, $value, $options, $attributes) 101 { 102 $widget = new sfWidgetFormSelect($options, $attributes); 103 return $widget->render($name, $value); 104 } 105 106 /** 107 * @param string $name 108 * @param string $value 109 * @param array $options 110 * @param array $attributes 111 * @return string rendered widget 112 */ 113 protected function renderMonthWidget($name, $value, $options, $attributes) 114 { 115 $widget = new sfWidgetFormSelect($options, $attributes); 116 return $widget->render($name, $value); 117 } 118 119 /** 120 * @param string $name 121 * @param string $value 122 * @param array $options 123 * @param array $attributes 124 * @return string rendered widget 125 */ 126 protected function renderYearWidget($name, $value, $options, $attributes) 127 { 128 $widget = new sfWidgetFormSelect($options, $attributes); 129 return $widget->render($name, $value); 130 } 99 131 } branches/1.4/lib/widget/sfWidgetFormDate.class.php
r16259 r24605 4 4 * This file is part of the symfony package. 5 5 * (c) Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 83 83 $emptyValues = $this->getOption('empty_values'); 84 84 85 // days86 $ widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')), array_merge($this->attributes, $attributes));87 $date['% day%'] = $widget->render($name.'[day]', $value['day']);85 $date['%day%'] = $this->renderDayWidget($name.'[day]', $value['day'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')), array_merge($this->attributes, $attributes)); 86 $date['%month%'] = $this->renderMonthWidget($name.'[month]', $value['month'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')), array_merge($this->attributes, $attributes)); 87 $date['%year%'] = $this->renderYearWidget($name.'[year]', $value['year'], array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), array_merge($this->attributes, $attributes)); 88 88 89 // months90 $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')), array_merge($this->attributes, $attributes));91 $date['%month%'] = $widget->render($name.'[month]', $value['month']);92 93 // years94 $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), array_merge($this->attributes, $attributes));95 $date['%year%'] = $widget->render($name.'[year]', $value['year']);96 89 97 90 return strtr($this->getOption('format'), $date); 98 91 } 92 93 /** 94 * @param string $name 95 * @param string $value 96 * @param array $options 97 * @param array $attributes 98 * @return string rendered widget 99 */ 100 protected function renderDayWidget($name, $value, $options, $attributes) 101 { 102 $widget = new sfWidgetFormSelect($options, $attributes); 103 return $widget->render($name, $value); 104 } 105 106 /** 107 * @param string $name 108 * @param string $value 109 * @param array $options 110 * @param array $attributes 111 * @return string rendered widget 112 */ 113 protected function renderMonthWidget($name, $value, $options, $attributes) 114 { 115 $widget = new sfWidgetFormSelect($options, $attributes); 116 return $widget->render($name, $value); 117 } 118 119 /** 120 * @param string $name 121 * @param string $value 122 * @param array $options 123 * @param array $attributes 124 * @return string rendered widget 125 */ 126 protected function renderYearWidget($name, $value, $options, $attributes) 127 { 128 $widget = new sfWidgetFormSelect($options, $attributes); 129 return $widget->render($name, $value); 130 } 99 131 }