reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

row call in template example does not work? #6

Closed seancorfield closed 10 years ago

seancorfield commented 10 years ago

As the examples stand, I can't get the form to render properly when row is called using square brackets in the template. If I change it to a regular call, in parentheses, it works just fine.

So

(defn row
  "Render a row of our form."
  [label t k]
  [:div
   [:label {:field :label :preamble label}]
   [:input {:field t :id k}]])

...
    (let [doc (atom {:first-name "" :last-name ""})
          doc-form [:div [row "First Name" :password :first-name]]
      [bind-fields doc-form doc])

does not work. But

    (let [doc (atom {:first-name "" :last-name ""})
          doc-form [:div (row "First Name" :password :first-name)]
      [bind-fields doc-form doc])

works fine.

I don't know whether this is a doc bug or a code bug - or whether something else in my environment is causing the difference?

seancorfield commented 10 years ago

This seems to be just a doc bug in the readme - the examples in the repo use ( calls ) instead of square brackets.

yogthos commented 10 years ago

Yeah, I should update the docs. The stuff in the template needs to be eagerly evaluated since bind-fields uses prewalk to create its elements. I'll fix the docs and make a note of that. :)

seancorfield commented 10 years ago

Thank you for fixing the docs (closing this ticket). And also thank you for this library - I've integrated into our World Singles app and it provides a big simplification!

yogthos commented 10 years ago

Really glad to hear it, if you have any suggestion for syntax improvements and such please let me know. I think I've covered the basics based on my usage, but I might've missed something obvious with the design and it would be good to catch that kind of thing early on.

yogthos commented 10 years ago

on an unrelated topic, I ended up porting some of the lib-noir namespaces to ClojureScript as well, might be useful reagent-utils. I find that I really like the lib-noir session API for dealing with the global state.

seancorfield commented 10 years ago

Nice!

yogthos commented 10 years ago

Just a heads up, I made a breaking API change in 0.1.3. The . in the :id key is now used to denote nested elements in the document. So, for example if you do [:input.form-control {:field :text :id :user.first-name}] this will be mapped to {:user {:first-name ...}} in the state atom.

seancorfield commented 10 years ago

Sounds good to me.