I have a start date element and an end date element in a form. Each are selected using a datepicker. I would like my form to automatically set the end date element of my form to be one day after the start date is selected (so, for example, if I select July 10, 2013, the value in the end date field should default to July 11, 2013). The user can make the end date whatever they want to from then on, but initially it should be the day after.
Here is my code for the form:
// Element: start_date
$start_date = new Zend_Form_Element_Text('start_date',
array(
'label' => 'Start date',
'required' => false,
'filters' => array('StringTrim', 'StripTags'),
'class' => 'input-small datepicker',
'decorators' => $customElementDecorators,
'data-date' => date("Y-m-d"),
'data-date-format' => 'yyyy-mm-dd',
'value' => date("Y-m-d")
)
);
// date validator
$start_date->addValidator(new Zend_Validate_Date('Y-m-d'));
$this->addElement($start_date);
unset($start_date);
// Element: end_date
$end_date = new Zend_Form_Element_Text('end_date',
array(
'label' => 'End date',
'required' => false,
'filters' => array('StringTrim', 'StripTags'),
'class' => 'input-small datepicker',
'decorators' => $customElementDecorators,
'data-date' => date("Y-m-d"),
'data-date-format' => 'yyyy-mm-dd',
'value' => date("Y-m-d")
)
);
$this->addElement($end_date);
unset($end_date);
Thanks in advance.