Added selectMonth and selectYear to FormBuilder.

This commit is contained in:
Taylor Otwell committed 2013-07-30 16:23:29 -05:00
1 parent 174edee831
commit 07eb181c23
1 file changed
+52
+52
View File
@@ -409,6 +409,58 @@ class FormBuilder {
return "<select{$options}>{$list}</select>";
}
/**
* Create a select range field.
*
* @param string $name
* @param string $begin
* @param string $end
* @param string $selected
* @param array $options
* @return string
*/
public function selectRange($name, $begin, $end, $selected = null, $options = array())
{
$range = array_combine($range = range($begin, $end), $range);
return $this->select($name, $range, $selected, $options);
}
/**
* Create a select year field.
*
* @param string $name
* @param string $begin
* @param string $end
* @param string $selected
* @param array $options
* @return string
*/
public function selectYear()
{
return call_user_func_array(array($this, 'selectRange'), func_get_args());
}
/**
* Create a select month field.
*
* @param string $name
* @param string $selected
* @param array $options
* @return string
*/
public function selectMonth($name, $selected = null, $options = array())
{
$months = array();
foreach (range(1, 12) as $month)
{
$months[$month] = strftime('%B', mktime(0, 0, 0, $month));
}
return $this->select($name, $months, $selected, $options);
}
/**
* Get the select option for the given value.
*