reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Add 'checked' attribute to checkbox component. Fix gh-97. #100

Closed hjrnunes closed 8 years ago

hjrnunes commented 8 years ago

This fixes issue #97

As far as I could see, the 'checked' attribute of the checkbox was not wired to the state atom, so that if you would reset it, the checkbox would not "un-check".

I used merge there because we only want to add "checked" if the checkbox is meant to be checked as the absence of that attribute is the only correct way of saying it shouldn't.

This should now work fine when you clear the form:

(defn annotate-pane []
  (let [doc (atom nil)]
    (fn []
      [:div
       [:p (str @doc)]
       [bind-fields
        [:input.form-control {:field :checkbox :id :first-name}]
        doc]
       [:button
        {:on-click #(reset! doc nil)}
        "clear"]])))
yogthos commented 8 years ago

Ah perfect, that makes sense to me.

yogthos commented 8 years ago

just pushed the fix to clojars with 0.5.22

hjrnunes commented 8 years ago

Cool thanks!