|
Size: | 13878 |
Storage flags: | no_autoload,compress/gzip (25%) |
Zend\Form\Element\MonthSelect is meant to be paired with the Zend\Form\View\Helper\FormMonthSelect. This element creates two select elements, where the first one is populated with months and the second is populated with years. By default, it sets 100 years in the past for the year element, starting with the current year.
Basic Usage
1 2 3 4 5 6 7 8 9 | use Zend\Form\Element;
use Zend\Form\Form;
$monthYear = new Element\MonthSelect('monthyear');
$monthYear->setLabel('Select a month and a year');
$monthYear->setMinYear(1986);
$form = new Form('dateselect');
$form->add($monthYear);
|
Using the array notation:
1 2 3 4 5 6 7 8 9 10 11 | use Zend\Form\Form;
$form = new Form('dateselect');
$form->add(array(
'type' => 'Zend\Form\Element\MonthSelect',
'name' => 'monthyear',
'options' => array(
'label' => 'Select a month and a year',
'min_year' => 1986,
)
));
|
Public Methods
The following methods are in addition to the inherited methods of Zend\Form\Element.
Returns the Select element that is used for the months part.
Return type: | Zend\Form\Element\Select |
---|
Returns the Select element that is used for the years part.
Return type: | Zend\Form\Element\Select |
---|
Set attributes on the Select element that is used for the months part.
Get attributes on the Select element that is used for the months part.
Return type: | array |
---|
Set attributes on the Select element that is used for the years part.
Get attributes on the Select element that is used for the years part.
Return type: | array |
---|
Set the minimum year.
Get the minimum year.
Set the maximum year.
Get the maximum year.
Set the value for the MonthSelect element.
If the value is an instance of \DateTime, it will use the month and year values from that date. Otherwise, the value should be an associative array with the month key for the month value, and with the year key for the year value.
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.