I've been stuck on this issue for days.
I'm having trouble updating a taxonomy field that uses checkboxes.
The data format I get back looks like:
{"uid":"6","name":"joe","mail":"joe@joe.com",
"field_categories":{"und":[{"tid":"2"},{"tid":"1"}]}
}
However I've worked out that I cannot PUT this back in this format as drupal is using the form processing and is expecting it in a different format as I get this error:
{"form_errors":{"field_categories][und":"An illegal choice has been detected. Please contact the site administrator."}}
Can anyone tell me the format it should be in if the form is expecting checkboxes?
Comments
Comment #1
timlie commentedI am also stuck on this issue.
Trying to PUT some multiple values in a text list field (checkboxes) like this:
{"type":"profile","field_multiple":{"und":[{"value":"10"},{"value":"11"},{"value":"12"}]}}{"form_errors":{"field_multiple][und":"An illegal choice has been detected. Please contact the site administrator."}}Comment #2
timlie commentedSolved the first part.
Checking with dpm($form_state) gave me the correct arrays the form uses with multiple checkboxes.
It had to be like this:
{"type":"profile","field_multiple":{"und":{"10":"10"}}}The only problem is that when I use:
{"type":"profile","field_multiple":{"und":[{"10":"10"},{"11":"11"},{"12":"12"}]}}to add multiple values the json code becomes
json['field_multiple']['und'][0]['10']json['field_multiple']['und'][1]['11']It automatically adds the [0], [1], ... which is wrong for the multivalue checkboxes.
Comment #3
timlie commentedFinally solved to get the correct json format (php script with json_encode() is very handy: check here).
{"type":"profile","field_multiple":{"und":{"10":"10","11":"11","12":"12"}}}Comment #4
timlie commented