deleted 2 characters in body
Source Link
jrothafer
  • 5.9k
  • 2
  • 11
  • 23

You may be using the incorrect field name. You can't access it via its short name, it has to be by it's field_id. Here is an example of how I do something like this:

// these are usually set at the top of my add-on, function, whatever, 
// for reference through out this PHP file, and also in case different site
// instances (staging, dev, whatever) happen to have different field_ids
// for the same fields, so it's easier to change when pushing around
$first_name_field_id  = "field_id_10";
$last_name_field_id   = "field_id_20";

// ...

// then later, after instantiating the Channel Entry model, you apply field values like so:
$entry->$first_name_field_id = "Eric";
$entry->$last_name_field_id  = "Idle";

You may be using the incorrect field name. You can't access it via its short name, it has to be by it's field_id. Here is an example of how I do something like this:

// these are usually set at the top of my add-on, function, whatever, 
// for reference through out this PHP file, and also in case different site
// instances (staging, dev, whatever) happen to have different field_ids
// for the same fields, so it's easier to change when pushing around
$first_name_field_id  = "field_id_10";
$last_name_field_id   = "field_id_20";

// ...

// then later, after instantiating the Channel Entry model, you apply field values like so:
$entry->$first_name_field_id = "Eric";
$entry->$last_name_field_id  = "Idle";

You may be using the incorrect field name. You can't access it via its short name, it has to be by it's field_id. Here is an example of how I do something like this:

// these are usually set at the top of my add-on, function, whatever, 
// for reference through out this PHP file, and also in case different site
// instances (staging, dev, whatever) happen to have different field_ids
// for the same fields, so it's easier to change when pushing around
$first_name_field_id = "field_id_10";
$last_name_field_id  = "field_id_20";

// ...

// then later, after instantiating the Channel Entry model, you apply field values like so:
$entry->$first_name_field_id = "Eric";
$entry->$last_name_field_id  = "Idle";
Source Link
jrothafer
  • 5.9k
  • 2
  • 11
  • 23

You may be using the incorrect field name. You can't access it via its short name, it has to be by it's field_id. Here is an example of how I do something like this:

// these are usually set at the top of my add-on, function, whatever, 
// for reference through out this PHP file, and also in case different site
// instances (staging, dev, whatever) happen to have different field_ids
// for the same fields, so it's easier to change when pushing around
$first_name_field_id  = "field_id_10";
$last_name_field_id   = "field_id_20";

// ...

// then later, after instantiating the Channel Entry model, you apply field values like so:
$entry->$first_name_field_id = "Eric";
$entry->$last_name_field_id  = "Idle";