I’m trying to use the Channel Entries API to programmatically create some entries and seem to have run into a bug.
I’m attempting to insert entries into channel #5 (Counties). It has one custom field (#17).
There are two custom fields in the EE installation that are required: “Summary” from channel #4 and “City” from channel #6.
My code looks like this:
$data = array(
'title' => 'some title',
'channel_id' => 5, // necessary because of other bug that is marked fixed for next release
'entry_date' => '2010-09-10 01:40 PM',
'field_ft_17' => 'xhtml',
'field_id_17' => 'whatever'
);
if ($this->EE->api_channel_entries->submit_new_entry(5, $data) === FALSE)
{
show_error('An Error Occurred Creating the Entry');
}A print_r of the errors set by the API looks like this:
Array (
[Summary] => The following field is required:
[City] => The following field is required:
)The culprit appears to be the following code in Api_channel_entries.php, function _check_for_data_errors, roughly line 1125:
// Required and custom fields
$this->EE->db->select('field_id, field_label, field_type, field_required');
$query = $this->EE->db->get('channel_fields');Seems like the solution would be to filter that database select on the current channel’s assigned field group.
Moved to Development and Programming by Moderator
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.