I'm looking for Zend_Form
elements which will allow me to integrate Zend_Date
values easily.
For example, I need a hour picker and a week day picker in my forms. for example, the hour picker should display all the hour values from 12:00 AM to 11:00 PM, and the week day picker should display all the available week days.
I was looking for some kind of integration between Zend_Form_Element_Select
and Zend_Date
, but I couldn't find any ready to use elements. I would like to use zend_date, so the localization settings I'm already using will be used here.
Ideally, this should be a zend form element that I can set the type of value i need, something like:
$hour = new Form_Element_DateSelect('hour');
$hour->setDateFormat(Zend_Date:HOUR);
or
$weekday = new Form_Element_DateSelect('hour');
$hour->setDateFormat(Zend_Date:DAYOFWEEK);
I can accomplish it using standard Zend_Form_Element_Select
and pre filling the values, however I'm curious if someone made elements for these cases or have an idea to make these elements reusable, and to support multiple date formats.
$hour = new Zend_Form_Element_Select('hour');
$hour->setRequired(true)
->setLabel('Hour:')
$this->addElement($hour);
$time = new Zend_Date();
$time->setTime('00:00:00');
for ($i=0;$i<=23;$i++) {
$hour->addMultiOption($time->get('HH:mm'), $time->toString(Zend_Date::TIME_SHORT));
$time->addHour(1);
}