I'm using Sonata Admin Bundle with Symfony2. I have a datetime field. This is my piece of code. Pretty simple.
->add('passportIssueDate', 'date')
But in the form I can select Year value only from 2008 to 2018. Is there a way to set different range? Thanks in advance.
You would use something like this:
$builder->add('dob', 'birthday', array('years' => range(1980, date('Y')), 'format' => 'dd-MMMM-yyyy'));
This means the Date Field (regardless of if it's DateTime, Date, or Birthday) will give you a range from 1980 in this case to the current year. To get a range including years in the future, you would use something like this:
$builder->add('startDate', 'date', array('years' => range(2012, 2020), 'format' => 'dd-MMMM-yyyy'));
This instance gives you a range from 2012 to 2010.
Furthermore, the 'format' => 'dd-MMMM-yyyy'
will format your date selection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With