Menu

Showing Stored Dates in IOTA SDK Edit Forms
📰

Showing Stored Dates in IOTA SDK Edit Forms

DEV Community: html·Robert Markovski·about 1 hour ago
#3ElniKjY
#devto2#devto#dev#value#stored
Reading 0:00
15s threshold

A Go templating fix for date inputs that came up blank.

Short answer

In IOTA SDK, date fields on edit pages didn't show the value stored in the database. The date field only rendered its default, and the datetime-local field passed a raw time.Time as an attribute value. The fix uses the stored value when present and formats it in the layout HTML expects. It was merged as PR #1031 and closed issue #340 .

The problem

Issue #340, filed by a maintainer, reported that date fields rendered by the CRUD builder on edit pages "are missing the value that is set in DB", and that the same issue appeared on other pages.

The fix

const dateTimeLocalLayout = "2006-01-02T15:04" . . . if val := mapping . Or ( f . value , f . defaultVal ) ; ! val . IsZero ( ) { attrs [ "value" ] = val . Format ( time . DateOnly ) } . . . if val := mapping . Or ( f . value , f . defaultVal ) ; ! val . IsZero ( ) { attrs [ "value" ] = val .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.