reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Possible addition to readme: Events: id as a sequence #102

Closed NathanSmutz closed 6 years ago

NathanSmutz commented 8 years ago

I presume this is because my form has multiple inputs:

Having bound an event like (fn [id value document] ...) For a fom input :item, id would be bound to (:item) rather than :item

yogthos commented 8 years ago

right each id is converted to a path in the document, so for :item you'd get (:item), but for :person.name you'd get (:person :name)

NathanSmutz commented 8 years ago

I wonder if the example in readme needs to change:

[bind-fields form-template doc (fn [id value {:keys [weight height] :as doc}](when %28and %28some #{id} [:height :weight]%29 weight height%29 %28assoc-in doc [:bmi] %28/ weight %28* height height%29%29%29))]

With an event on :weight, (some #{id} [:height :weight]) would evaluate to:(some #{(:weight)} [:height :weight])

The Events section in the readme seems to imply that bare keywords are passed. Is there a case where that happens?

yogthos commented 8 years ago

The id gets translated to a path here. So you should be able to supply an id such as :person.name for a nested path.