backbone.syphon icon indicating copy to clipboard operation
backbone.syphon copied to clipboard

Unselected radio group is not present in serialized data

Open stephanebachelier opened this issue 9 years ago • 5 comments

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.

stephanebachelier avatar Apr 08 '15 08:04 stephanebachelier

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 avatar Apr 13 '15 23:04 rhubarbselleven

@rhubarbselleven then I'll come back to you soon :)

stephanebachelier avatar Apr 14 '15 06:04 stephanebachelier

@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.

stephanebachelier avatar Apr 15 '15 09:04 stephanebachelier

@rhubarbselleven Coming back here. I've updated my PR and rebased on top of master which is the last available.

stephanebachelier avatar May 12 '16 19:05 stephanebachelier

Would love to see it merged. Have exactly same issue with checkbox'es and radio.

ishaikovsky avatar Oct 04 '16 18:10 ishaikovsky