Bug #23307 Bug Fixed

Unable to save content to fields added to channel after first fields were added

Version: 4.0.0 Reporter: Jeremy Gimbel - Conflux Group

I have created a number of channels and added fields from the Fields tab of the channel/edit screen. These fields works and save fine.

However, when I create a field later and add it to a channel, I’m unable to save any content to the field. I get a success message that the entry has saved and any of the original fields do save correctly, but the new fields do not.

This is a brand new fresh install of 4.0.0 downloaded today.

  • Thanks for catching this Jeremy. I’ve posted a fix; can you give it a try to confirm it works?

    Seth Barber
    08th December, 2017 at 11:33am
  • Confirmed. Much better!

    Jeremy Gimbel - Conflux Group
    08th December, 2017 at 11:39am

You must be signed in to comment on a bug report.

  • In system/ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php replace lines 479 - 494 with:

    $query->where($key_column, $this->getId());
    $query->from($field->getTableName());
    $result = $query->get();
    
    $query = ee('Model/Datastore')->rawQuery();
    
    // When a new entity is saved, this will be triggered by an
    // onAfterInsert event (else, we won't have id to link to).
    // The primary key can only be marked dirty on an insert event,
    // not an update.
    if ($result->num_rows())
    {
        $query->set($values);
        $query->where($key_column, $this->getId());
        $query->update($field->getTableName());
    }
    else
    {
        $values[$key_column] = $this->getId();
        $query->set($values);
        $query->insert($field->getTableName());
    }

ExpressionEngine News

#eecms, #events, #releases