Fork me on GitHub
Chris Swanson18:06:06

i'm a little confused with form state and add-form-config* , would appreciate if someone has a minute to tell me what i'm doing wrong

Chris Swanson18:06:30

i've got a form for a "Profile" entity, and a sub-form for a "ContactInfo" entity

Chris Swanson18:06:57

the problem is that the helpers for dirty fields aren't picking up changes to the sub-form

Chris Swanson18:06:58

From what I can tell, the ContactInfo form state was at least partly initialized, because if I call fs/dirty? using params from within that component, it works as expected. But I thought it should also be recursive if I call it on the params from the Profile component

Chris Swanson18:06:00

For example, on line 20 it disables the save button if the form isn't dirty. This works fine to enable the button when I modify :profile/first-name, but it doesn't work when I modify :contact-info/home-phone

Chris Swanson19:06:56

My best guess is that the edit to the :contact-info/home-phone field causes a re-render of ContactInfo component but not the parent Profile component, so the params on the onclick transact lambda don't get updated

Chris Swanson19:06:27

but i'm still not sure what's the right way to do it

Chris Swanson19:06:41

Yea, confirmed that switching to keyframe render-mode solves the problem. But if someone's got advice about a better way, I'd love to hear


from a first scan of the code the thing that stands out is that neither of them have initial-state set


I had to add the following to a component to get the form state working:

;; in initial-state:
     :answer-prompt         (fs/add-form-config AnswerPrompt
                                                (prim/get-initial-state AnswerPrompt))

Chris Swanson20:06:36

interesting, looks promising. thanks, i'll give it a try