insin / insin/newforms

SplitDateTimeWidget, etc fields aren't tracked in state (form.data)?

Open
#112 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
634
Forks
46
PR merge metrics
No merged PRs in 30d

Description

I've been working on writing a custom MultiWidget Widget. However, I ran into a snag that the keys of the inputs were not in valueFromData's data argument unless they were explicitly interacted with. Once you gave a multiwidget's input focus and blurred, then the key/val for that specific input was available in the form.data argument, but no others of the same MultiWidget.

I tested this behavior on the stock SplitDateTimeWidget and it feels similar. My guess is that the fields are not being initialized in the state tracking of the form? This is evidenced when focusing in some other field. It does appear that decompress is being called initially to populate the field, but it just seems like it isn't being put in the virtual dom perhaps?
I have controlled: true on my form with onChange: this.forceUpdate.bind(this)

I'm not sure if this is a bug or a newbie issue.

Update: As per my followup below, this is happening on the "all fields" example as well when modified to have initial data.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.