backbone.syphon
backbone.syphon copied to clipboard
Unselected radio group is not present in serialized data
Hi,
I've found that if you serialize a form with a radio group with no button checked, the serialize object will not contain any value. I would like to have a different behavior: provide the name (or whatever key is used) of the radio group with an empty value.
I can provide a PR if you are willing to accept this behavior.
Thanks @stephanebachelier
To include or exclude keys due to the presence of a value is a bit inconsistent in a number of places, thanks for bringing this up. The current behaviour of Syphon is as you described: key with an empty value.
A PR would be fabulous :+1:
@rhubarbselleven then I'll come back to you soon :)
@rhubarbselleven it's done. I've added a new registry to Syphon which ValueAssigners
. The idea is be able to override for any type how the value is assigned.
I've added lots of tests and you could see in https://github.com/stephanebachelier/backbone.syphon/commit/b5553337e5b31417f40aea30489e1f786a9c5d12#diff-c0efbcd7d0b47db913f31f6b7c75333cR195 a possible usage.
I think the ValueAssigners
should helps with #34.
@rhubarbselleven Coming back here. I've updated my PR and rebased on top of master which is the last available.
Would love to see it merged. Have exactly same issue with checkbox'es and radio.