YearChoiceList.php 697 B

123456789101112131415161718192021222324
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\ChoiceList;
  11. class YearChoiceList extends PaddedChoiceList
  12. {
  13. public function __construct(array $years = array(), array $preferredChoices = array(), $emptyValue = '', $required = false)
  14. {
  15. if (count($years) === 0) {
  16. $years = range(date('Y') - 5, date('Y') + 5);
  17. }
  18. parent::__construct($years, 4, '0', STR_PAD_LEFT, $preferredChoices, $emptyValue, $required);
  19. }
  20. }