time column/field not showing
time column/field not showing
Hi, I'm having an issue in both datatables and editor with a time field. I don't want to use the timepicker, so I am not setting the column as a type of datetime. Postgres database, column is time with timezone.
It seems to save fine after editing in the database, but the value doesn't show in the datatable nor in the editor. In my editor.php , which is also the ajax url for the datatable I have:
Field::inst( 'historical_avalanche.etime' )
->validator( Validate::dateFormat( 'H:i' ) )
->getFormatter( Format::datetime( 'H:i:s', 'H:i' ) )
->setFormatter( Format::datetime( 'H:i', 'H:i:s' ) ),
ON the client side,the datatable column (no special rendering):
{"data": "historical_avalanche.etime", "title": "Time", orderable: false },
and the editor field :
{
"label": "Time",
"name": "historical_avalanche.etime"
}
I'm sure I am just missing something obvious, but can't seem to track it down in the forums.
Thanks.
Answers
That all looks okay there. Can you show me the data being submitted on edit and also the JSON being returned from that Ajax request please?
Allan
I edited some fields out for brevity, but it is the etime column that is of interest.
Here is payload being submitted:
and here is response:
And in the database is:
14:00:00-07:00
THanks.
Many thanks. I can see that
"etime": null,
is being returned from the server, even although14:00
is being submitted. That suggests to me that thegetFormatter
might be at fault here.What happens if you comment out the
getFormatter
? When the data is loaded, what does the data look like?Thanks,
Allan
When I comment out the getFormatter it loads, but has the timezone designation in it.
To review, here is what I have:
And it shows as '15:00:00-07'