time column/field not showing

time column/field not showing

capeckcapeck Posts: 49Questions: 12Answers: 1

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

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    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

  • capeckcapeck Posts: 49Questions: 12Answers: 1

    I edited some fields out for brevity, but it is the etime column that is of interest.

    Here is payload being submitted:

    data[34016][historical_avalanche][edate]: 
    12/03/22
    data[34016][historical_avalanche][etime]: 
    14:00
    data[34016][historical_avalanche][pathname]: 
    willow creek
    data[34016][historical_avalanche][avy_type]: 
    HS
    data[34016][historical_avalanche][trigger]: 
    AA
    data[34016][historical_avalanche][significant_event]: 
    0
    data[34016][historical_avalanche][aspect]: 
    data[34016][historical_avalanche][slope]: 
    data[34016][historical_avalanche][depth]: 
    data[34016][historical_avalanche][surface]: 
    U
    
    action: 
    edit
    

    and here is response:

    {"data":[{"DT_RowId":"row_34016","historical_avalanche":{"id":34016,"edate":"12\/03\/22","etime":null,"pathname":"willow creek","avy_type":"HS","trigger":"AA","relative_size":"0","destructive_size":"0","depth":null,"surface":"U","vertical":null,"notes":"","location":"BC","gis_name":null,"aspect":"","elevation":null,"slope":"","zone":"JHMR","latitude":"42.837","longitude":"-110.779","public_notes":"","significant_event":0,"web_id":null,"sm_id":null,"nac_avy_id":"642cf16f-0fa4-4754-bc11-e17031dbbd11"}}],"debug":[{"query":"SELECT  \"historical_avalanche\".\"id\" as \"historical_avalanche.id\" FROM  \"historical_avalanche\" WHERE \"historical_avalanche\".\"id\" = :where_0 ","bindings":[{"name":":where_0","value":"34016","type":null}]},{"query":"UPDATE  \"historical_avalanche\" SET  \"edate\" = :edate, \"etime\" = :etime, \"pathname\" = :pathname, \"avy_type\" = :avy_type, \"trigger\" = :trigger, \"relative_size\" = :relative_size, \"destructive_size\" = :destructive_size, \"depth\" = :depth, \"surface\" = :surface, \"vertical\" = :vertical, \"notes\" = :notes, \"location\" = :location, \"aspect\" = :aspect, \"elevation\" = :elevation, \"slope\" = :slope, \"zone\" = :zone, \"latitude\" = :latitude, \"longitude\" = :longitude, \"public_notes\" = :public_notes, \"significant_event\" = :significant_event WHERE \"historical_avalanche\".\"id\" = :where_0 ","bindings":[{"name":":edate","value":"2022-12-03","type":null},{"name":":etime","value":"14:00:00","type":null},{"name":":pathname","value":"willow creek","type":null},{"name":":avy_type","value":"HS","type":null},{"name":":trigger","value":"AA","type":null},{"name":":relative_size","value":"0","type":null},{"name":":destructive_size","value":"0","type":null},{"name":":depth","value":null,"type":null},{"name":":surface","value":"U","type":null} FROM  \"historical_avalanche\" WHERE \"historical_avalanche\".\"id\" = :where_0 ","bindings":[{"name":":where_0","value":"34016","type":null}]}]}
    

    And in the database is:
    14:00:00-07:00

    THanks.

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    Many thanks. I can see that "etime": null, is being returned from the server, even although 14:00 is being submitted. That suggests to me that the getFormatter 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

  • capeckcapeck Posts: 49Questions: 12Answers: 1

    When I comment out the getFormatter it loads, but has the timezone designation in it.
    To review, here is what I have:

    >getFormatter( Format::datetime( 'H:i:s', 'H:i' ) )
    

    And it shows as '15:00:00-07'

Sign In or Register to comment.