Fork me on GitHub
#fulcro
<
2020-12-05
>
Buidler16:12:37

I'm getting a FORM NOT NORMALIZED error when submitting a form. It has just a single field, text, and does not have any initial state set in the client code or loaded from the server. My form component has an ident :ident (fn [] [:note-form :singleton]) and its query has a form config join :query [:note/id :note/text #p fs/form-config-join]. Why am I still getting this error?

Buidler17:12:26

Also, what is a reconciler? I see mentions of it in the docs but no explanation/definition of it.

tony.kay17:12:50

@randumbo you using f3? There is no reconciler…it was in f2…I thought I fixed all of those

Buidler17:12:26

Ah, musta got my urls mixed up, I was going to https://book.fulcrologic.com/fulcro3/ which looks outdated. There is just one mention of the reconciler in this example of the proper docs https://book.fulcrologic.com/#MergingwithaComponent

tony.kay17:12:00

ooops. that should redirect

tony.kay17:12:29

I added a redirect…didn’t realize I’d left that there

tony.kay17:12:42

book was updated yesterday, so the rev date at top should be pretty recent

Buidler17:12:37

Got it, ty.

tony.kay17:12:26

you’re going to need to add initial state to that form..or there is nothing in state for it (it esp isn’t hooked to the data graph)

Buidler17:12:02

So just an empty string for the text field should suffice?

Buidler18:12:57

Normally you might throw this into your application state with something like:

(merge/merge-component! app PersonForm person-tree)
Where would you put that? I'm not grasping how the form component definition and that part go together. I'm guessing it's not supposed to just go on my mutation helper that saves the person?

Buidler18:12:27

Think I'm gonna rewatch the Part 10 : Form Inputs and State video and maybe the ones after it. Maybe it'll clear things up for me.

Buidler19:12:30

I'm trying to follow along with Part 11 on form state. I notice that when I apply the same logic (merge-component followed by add-form-config*), my pristine-state does not get populated.

{:note-form {:singleton {:note/id 22, :note/text "Original"}},
 :com.fulcrologic.fulcro.algorithms.form-state/forms-by-ident
 {{:table :note/id, :row 22}
  {:com.fulcrologic.fulcro.algorithms.form-state/id [:note/id 22],
   :com.fulcrologic.fulcro.algorithms.form-state/fields #{:note/text},
   :com.fulcrologic.fulcro.algorithms.form-state/pristine-state {},
   :com.fulcrologic.fulcro.algorithms.form-state/subforms {}}},
 :note/id
 {22
  {:com.fulcrologic.fulcro.algorithms.form-state/config
   [:com.fulcrologic.fulcro.algorithms.form-state/forms-by-ident
    {:table :note/id, :row 22}]}}}
I think it's because I have just a single form with :ident [:note-form :singleton] and I'm trying to create notes from it... but I can't quite understand how to use it properly so it tracks the form state like it's supposed to. Am I abusing the singleton concept here? I only need a single instance of this form, I thought a singleton would be fitting.

tony.kay19:12:51

object goes in state -> add-form-state adds pristine and form config -> you interact with it (modify the normal entity) -> tell form state you’re done (mark complete) -> form state can calc diffs It’s all View = Function(State), where State is being evolved. Most people struggle I think because they think they’re in some mutable forms library in js or something. This is functional. This uses pure data. Fulcro is always State1 -> render -> state2 -> render … So, you have to create a sequence of states that represent the interaction. Form state is just some helpers that help you do that. And yes, forms are rarely singletons unless the database item is a singleton, so you seem to be abusing the singleton concept as well.

Buidler20:12:03

The form should be initialized with a tempid and blank string my case, where the [:note/id tempid] is the form's ident, and then after the form is submitted, the :note/text is set to an empty string and a new tempid is used for the new NoteForm ident, instead of the singleton?

tony.kay21:12:00

pretty much…there are demos in the book

Buidler22:12:53

Yes, I've looked at many of the demos. It's just a lot to infer from when many of the concepts are new. I'm used to Django and Fulcro is a treat to learn, but it's a significant shift. I think I understand my the form mistakes I was making. Going to try to continue on and incorporate UISM.

Buidler22:12:49

Thanks for the help. Wish I didn't have to ask as many questions :)