Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkbox support. Use "checked" instead of "default-checked" #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cljs/free_form/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{:keys [value-on error-on extra-error-keys]} free-form-attributes
on-change-fn #(on-change keys (extract-event-value %1))
value-on (or value-on (case (:type attributes)
(:checkbox :radio) :default-checked
(:checkbox :radio) :checked
:value))
value (case (:type attributes)
:checkbox (= true (get-in values keys))
Expand Down
16 changes: 8 additions & 8 deletions test/cljs/free_form/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
[:div {}
[:input {:type :checkbox
:id :checkbox
:default-checked false
:checked false
:on-change :was-function}]
[:label {:for :checkbox} "Checkbox"]
nil]
Expand All @@ -204,21 +204,21 @@
[:input {:type :radio
:name :radio-buttons
:value "radio-option-1"
:default-checked false
:checked false
:on-change :was-function}]
"Radio Option 1"]
[:label
[:input {:type :radio
:name :radio-buttons
:value "radio-option-2"
:default-checked false
:checked false
:on-change :was-function}]
"Radio Option 2"]
[:label
[:input {:type :radio
:name :radio-buttons
:value "radio-option-3"
:default-checked false
:checked false
:on-change :was-function}]
"Radio Option 3"]
nil]
Expand Down Expand Up @@ -306,23 +306,23 @@
[:div {}
[:input {:type :checkbox
:id :checkbox
:default-checked true
:checked true
:on-change :was-function}]
[:label {:for :checkbox} "Checkbox"] nil]
[:div.plain-field {}
[:label [:input {:type :radio
:name :radio-buttons
:value "radio-option-1"
:default-checked false
:checked false
:on-change :was-function}] "Radio Option 1"]
[:label [:input {:type :radio
:name :radio-buttons
:value "radio-option-2"
:default-checked true
:checked true
:on-change :was-function}] "Radio Option 2"]
[:label [:input {:type :radio
:name :radio-buttons
:value "radio-option-3"
:default-checked false
:checked false
:on-change :was-function}] "Radio Option 3"] nil]
[:button "Button"]]))))))