Dear all,
After questioning google the whole day, I am eventually opening this issue...
I'm trying to create a node (endpoint, create node) consisting of, among others,
the following structure:
field_citcomponent_devref (Array, 17 elements)
und (Array, 25 elements)
0 (Array, 11 elements)
1 (Array, 11 elements)
uid (Array, 36 elements)
Usually the field is filled via the user_reference_autocomplete widget in the UI
which works well, also for 10+ user references. However, I am able to fill the _FIRST_ value
using the node create endpoint with this JSON syntax:
"field_citcomponent_devref": {
"und": [ {"uid":"my_user_name"} ]
}
I tried several mappings of the Drupal array structure but nothing is working, here
are some examples (not working):
"field_citcomponent_devref": {
"und": [ {"uid":"my_user_name"}, {"uid":"other_user_name"} ]
}
"field_citcomponent_devref": {
"und": [ "0": {"uid":"my_user_name"}, "1": {"uid":"other_user_name"} ]
}
Can anybody tell me why the syntax of the JSON string passed via POST is completely
different depending on the widget the actual form makes use of?
More importantly, has anyone managed to add multiple references to a multi-value field
which uses the auto-complete widget?
I also need to do this with node references...
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | multi-value-field.patch | 2.29 KB | flier |
Comments
Comment #1
flier commentedComment #2
marcingy commentedSupport request are never more than normal
Comment #3
flier commentedYeah, didn't have a look at that, I'm sorry.
In the meantime I encoded the $form as JSON using drupal_encode_json($form) on submit()
This is how the field looks like in JSON:
Doesn't work at creation time either. I suppose there is something wrong with
the JSON parser...
Comment #4
flier commentedI've come up with a partial solution for this. If you set the number of allowed values to a specific number, say 10 you can add up to 10 user references.
This, however, is IMHO a major design flaw of services since it makes use of the form and thus of the widget, so your JSON Format is dependent on the selected widget.
I will try to come up with a hot fix.
Comment #5
marcingy commentedSee https://drupal.org/node/1985390
Comment #6
flier commentedHi thank you for that link, so this won't fix?
Comment #7
flier commentedHere's my patch for multi-value fields.
It's trivial and pretty much straight forward (if you know
all the Drupal internals ... )
Basically I just make use of the rebuild_form() function
including additional fields which are parsed from the
$form_state array
Comment #8
marcingy commentedClosing as duplicate of #2224803: Possible patch for multi-value fields