ulion / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Twitter Bootstrap out of the box.
http://ulion.github.io/jsonform/playground/
MIT License
49 stars 27 forks source link

Bug with checkboxbuttons default values #33

Open adam-clarey opened 8 years ago

adam-clarey commented 8 years ago

Currently default values will only be applied if there is more than one field set as 'checked'.

I've found and fixed the issue and supplied the patch. Essentially, the onBeforeRender function expects the values to be in an array, but a single value does not appear in an array. checkboxes-defaults.patch.txt

adam-clarey commented 8 years ago

Correction patch, the values need to be in an array, so this patch puts a single value into an array checkboxes-defaults.patch.txt

ulion commented 8 years ago

checkboxbuttons expect the value be an array.

so either your default value, or the preloaded value, should be an array. it's not the code's responsibility to fix the value type imo.

2016-06-03 18:10 GMT+08:00 adam-clarey notifications@github.com:

Correction patch, the values need to be in an array, so this patch puts a single value into an array checkboxes-defaults.patch.txt https://github.com/ulion/jsonform/files/297376/checkboxes-defaults.patch.txt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ulion/jsonform/issues/33#issuecomment-223542150, or mute the thread https://github.com/notifications/unsubscribe/AAKsHaS6TByWQ5DN5eLuJN2s3GD6pr4Yks5qH_2QgaJpZM4ItWQt .

Ulion