I'm using cURL in PHP to do this.
The syntax I'm looking for is for the last key/value pair in this array:
$node_data = array(
'title' => $title,
'type' => 'place',
'body[und][0][value]' => $body,
'field_place_country[und][0][value]' => $field_place_country,
'field_place_latitude[und][0][value]' => $field_place_latitude,
'field_place_longitude[und][0][value]' => $field_place_longitude,
'field_legacy_id[und][0][value]' => $field_legacy_id,
'field_place_alternate_name[und][0][value]' => 'test a',
'field_place_related_document[und][0][target_id]' => $field_place_related_document_id,
);
What should the syntax be, rather than: field_place_related_document[und][0][target_id]
?
Thank you,
Doug
Comments
Comment #1
DUG1138 commentedComment #2
DUG1138 commentedComment #3
s.daniel commentedNot sure if this is the same kind of reference you are looking for in any case it might help someone who stumbles upon this issue: http://drupal.org/node/1354202
Comment #4
DUG1138 commentedComment #5
marcingy commentedWith an attitude like that......it is volunteer project if you want an urgent solution go pay someone.
Comment #6
DUG1138 commentedOk, Marc.
I'll pay you $10, if you can answer the question with a solution that works.
note: there can be more than one entity reference in the data I'm importing, so I'm going to need something that works along these lines:
field_place_related_document[und][0][target_id]
field_place_related_document[und][1][target_id]
field_place_related_document[und][2][target_id]
...
field_place_related_document[und][n][target_id]
Will PayPal work for you?
Comment #7
DUG1138 commentedComment #8
DUG1138 commentedComment #9
marcingy commentedI don't want paid I simply have a) no time b) no desire to answer your question given your attitude. If you want paid help go and create an entry on drupal.org/paid-services.
Comment #10
DUG1138 commentedComment #11
marcingy commentedPlease do not re-open this issue, it is going to stay closed as I say if you want paid help use the appropriate channel on d.o.
Comment #12
azicchetti commentedIf the field is using the autocomplete widget, you have to use this format:
'field_place_related_document[und][0][target_id]' => "anything ({$field_place_related_document_id})",
The form handler automatically gets the node id from the parenthesis.
Comment #12.0
azicchetti commentedminor syntax adjustment
Comment #13
gejo commentedI had this problem with an ajax call (phonegap app).
Syntax suggested by #12 worked for me, as I'm using the autocomplete widget at the field definition:
...'&node[field_entityreference][und][0][target_id]=anything (' + encodeURIComponent(nid_reference) + ')'...Also suggested here.
Thanks to azicchetti.