7.3.5.3 year
There is no translation yet for this section. Please help out and translate this.. More information about translations
year(string $fieldName, int $minYear, int $maxYear, mixed $selected, array $attributes, mixed $showEmpty)
Creates a select element populated with the years from $minYear to $maxYear, with the $selected year selected by default. $selected can either be a four-digit year (e.g. 2004) or string 'now'. HTML attributes may be supplied in $attributes.
<?php
echo $form->year('purchased', 2005, 2009);
?>
<?phpecho $form->year('purchased', 2005, 2009);?>
Will output:
<select name="data[User][purchased][year]" id="UserPurchasedYear"> <option value=""></option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> </select>
If $showEmpty is false, the select will not include an empty option. If $showEmpty is a string, it will be used as empty option's name.
<?php
echo $form->year('returned', 2008, 2010, null, null, 'Select a year');
?>
<?phpecho $form->year('returned', 2008, 2010, null, null, 'Select a year');?>
Will output:
<select name="data[User][returned][year]" id="UserReturnedYear"> <option value="">Select a year</option> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> </select>


























