I'm using jQuery.serializeJSON (https://github.com/marioizquierdo/jquery.serializeJSON). Basically, I have a form like:
<input name='store[products][][type]' type='text' value='TableSaw' />
<textarea name='store[products][][description]'></textarea>
<textarea name='store[products][][price]'></textarea>
Which when serialized looks like:
{"store":{"products":[{"type":"TableSaw","description":"Really cool saw, should buy it ","price": "20.99"}]}}
The user can change/delete/ description, price, and other attributes.Basically, what I want to do is test if type is the only key present.
Right now it looks like:
{"store":{"products":[{"type":"TableSaw"}]}} //JUST TYPE IS SENT TO DB. NOT WHAT I WANT
But what I'm trying to achieve is:
{"store":{"products":[]}} //WHAT I WANT TO SEND TO DB.
if only type is set, and nothing else.