I’ve setup a primary channel ‘project’ for my latest website.
I have numerous other channels that will serve as the children channels to this; on each of those I’ve identified one field as the relationship link which should simulate my foreign key relationship back to the parent.
When creating a child entry from the front end, I was creating the connection to the parent by assigning the project entry_id as a hidden field in my SafeCracker form:
<table>
<tr><td class='form_text'>Member Position:</td><td>{field:member_entry_type}</td></tr>
<tr><td class='form_text'>First Name:</td><td>{field:member_first_name}</td></tr>
<tr><td class='form_text'>Last Name:</td><td>{field:member_last_name}</td></tr>
<tr><td colspan='2'>
<input type='hidden' id='volunteer_entry_race_id' name='member_entry_project_id' value='{segment_3}'/>
<input type='hidden' id='title' name='title' value='Member Entry - <?php echo $title; ?>'/>
<input type="submit" value="Submit">
</td></tr></table>
This works when I assign the value, but any time I try to reference the value down the road, it doesn’t pull the right value. In the example below, segment_3 is the parent_id. I was just trying out an update_entry API call, but when I echo the project ID I previously set, that’s where I display the unexpected value.
$child_id = '{segment_3}';
$this->EE->load->library('api');
$this->EE->api->instantiate('channel_entries');
$this->EE->api->instantiate('channel_fields');
{exp:channel:entries channel="member_entries" entry_id="{segment_3}"}
echo '{member_entry_project_id}';
$data = array(
'channel_id' => 10,
'title' => '{title}',
'entry_date' => {entry_date},
'field_id_49' => '{member_entry_project_id}',
'field_ft_49' => 'none',
'field_id_50' => '{member_entry_type}',
'field_ft_50' => 'none',
'field_id_51' => '{member_first_name}',
'field_ft_51' => 'none',
'field_id_51' => '{member_last_name}',
'field_ft_52' => 'none'
);
{/exp:channel:entries}
?>
In researching other posts, it appears I’m pulling back the relationship ID and not the parent ID I originally set. This lead me to think that I was approaching this incorrectly. Is there another way I should approach this?
Thanks,