reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Checkbox not linked to the 'checked' attribute #40

Closed Quantisan closed 9 years ago

Quantisan commented 9 years ago

When I default check a checkbox with [:input {:type :checkbox :checked true}], user can't manually uncheck it. It appears that the checkbox value is not updated by check/uncheck. So right now I'm just hacking it with an atom state and doing :on-click to swap the attribute. Is that the recommended way?

Any suggestion on how to get checkbox to just work out of the box with reagent-forms? I can submit a pull request if you give me some pointers.

yogthos commented 9 years ago

Sounds like you just have to handle the additional case for the state of the checkbox component. A pr sounds great, let me know if you need any additional pointers with it.

Quantisan commented 9 years ago

Turns out there's a defaultChecked property that should have been used. This works out of the box:

[:input {:type :checkbox :name :foo :value true :defaultChecked true}]