1

Based on the documentation, here is the signature for the method that inserts a new entry or update an existing one.

ee()->api_channel_entries->save_entry($data, $channel_id, $entry_id, $autosave);

My question is that, what should be the contents for $data?

Say for example I have Channel A which has only one custom field, "foo"

Do I do this?

$data = array (
    'title' => 'bar',
    'url_title' => 'bar'
    'foo' => 'bar'
);

or this?

$data = array (
    'title' => 'bar',
    'url_title' => 'bar'
    'field_id_<field id of foo>' => 'bar'
);

Or is the contents of $data should be something else entirely? Do I need to input required field?

4

This is a pretty late answer, and you likely already figured it out, but the $data array should use the database 'field_id_#' as the array key. So if the field id of your custom field 'foo' is 5, for example, then your data array would be:

$data = array (
    'title' => 'bar',
    'url_title' => 'bar',
    'field_id_5' => 'bar',
);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.