I need to use the channel entries API to save a relationship between two channels. I create an entry to channel A and then I create an entry to Channel B, channel B has a relationship field that needs to be set to point to the entry on Channel A.
I can create the entries with the save_entry() function, but I can't decipher how to set the relationship field on Channel B to Channel A.
My process is:
when I create the entry on Channel A I use the entry ID and pass it as the value of Channel B's relationship field. This does not work.
$channel_b_entry = array(
'title' => $data['title'],
'field_id_26' => $data['type'],
'field_id_29' => $data['channel_a_entry_id'],
'field_ft_29' => 'xhtml',
);
In this case field_id_29 is a relationship field to channel A entries.
I have tried passing the id as an array
$channel_b_entry = array(
'title' => $data['title'],
'field_id_26' => $data['type'],
'field_id_29' => array($data['channel_a_entry_id']),
'field_ft_29' => 'xhtml',
);
But that didn't work either.
Do I need to setup the relationship my self to the exp_relationship table, or the save_entry() takes care of that?