Issues

ZF-7813: setValue() doesn't work for TimeTextBox and DateTextBox form elements

Description

It seems like setValue() does nothing for TimeTextBox and DateTextBox. Following examples don't work. \


$this->addElement('TimeTextBox', 'myTime', array(
    'required'           => true,
    'label'              => 'myTime',
    'timePattern'        => 'HH:mm',
    'visibleRange'       => 'T02:00:00',
    'visibleIncrement'   => 'T00:30:00',
    'clickableIncrement' => 'T00:15:00',
    'value'              => '08:00'
));

$this->addElement('TimeTextBox', 'myTime', array(
    'required'           => true,
    'label'              => 'myTime',
    'timePattern'        => 'HH:mm',
    'visibleRange'       => 'T02:00:00',
    'visibleIncrement'   => 'T00:30:00',
    'clickableIncrement' => 'T00:15:00'
));
$this->getElement('myTime')->setValue('08:00');

// In controller
$myTimeForm->getElement('myTime')->setValue('08:00');

Comments

The value has to be in the correct form that isn't the form how user would fill the field. For example '08:00' -> 'T08:00:00'.

I think that this isn't the issue anymore.

I think Kim is right when saying that you should just give the value Dojo expects. I can however imagine this all to accept instances of Zend_Date...

Tests for asserting that value can be set on DateTextBox and TimeTextBox elements.

Closing this as not an issue.

Will open a ticket against ZF2 to add the possibility of passing a Zend\Date to DateTextBox and TimeTextBox.

I've reviewed the patch and confirm it operates as intended. Recommend committing to trunk and merging to release branch.

bq. Closing this as not an issue. I think that the problem here was that one cannot set value by saying {{setValue('08:00')}} but {{setValue('T08:00')}}.

bq. Will open a ticket against ZF2 to add the possibility of passing a Zend\Date to DateTextBox and TimeTextBox. In ZF2 this setter should accept all valid time formats in string too so that 08:00 is as valid as T08:00.

Committed the attached tests to r24460