DateTime form field shows only Date, no Time

Hi,

I have specified below in my volt file:

<td><label for="hr_emp_dob">DOB:</label> </td>
<td> {{ form.render("hr_emp_dob", ['class': 'form-control', "type" : "datetime" ]) }} </td>

The compiled phtml file shows:

<td><label for="hr_emp_dob">DOB:</label> </td>
<td> <?= $form->render('hr_emp_dob', ['class' => 'form-control', 'type' => 'datetime']) ?> </td>

The browser shows only dd-mm-yyyy in the field even though a datetime value exists for the field as you can see below, i.e. no data. The browser source shows:

<input type="date" id="hr_emp_dob" name="hr_emp_dob" value="1990-02-03 13:20:48" class="form-control" placeholder="DOB">

How is input type getting converted from datetime to date? I have tried giving the type in corresponding Form but it has not helped. If I go into Chrome Developer tools and change type from date to datetime for hr_emp_dob field then the value shows up in the form and also gets saved in table after any edit. Is this a bug or expected. I am using bootstrap and AdminLTE theme.

Thanks

Hi Amal you must create an datetime form element or use a simple Tag::tagHtml()

edited Mar '17

I have some examples for DateTime and Time:

class DateTime extends \Phalcon\Forms\Element\Date {

    public function render($attributes = null) {

        $html = \Phalcon\Tag::dateTimeLocalField($this->prepareAttributes($attributes));

        return $html;
    }
}

class Time extends \Phalcon\Forms\Element\Date  {

    public function render($attributes = null) {

        $html = \Phalcon\Tag::timeField($this->prepareAttributes($attributes));

        return $html;
    }
}