I am trying to update a custom field on an EntryModel. I'm having half success, and I don't understand why. I've looked at other posts such as this one by Brandon which discuss how to assign these values and I'm still not having any luck.
The EntryModel I'm trying to update is available in my field type in the
onAfterElementSave method via
$this->element. The handle for the field I want to be updating the value of is available via
I have tried using
getContent()->setAttributes() and they all seem to return the same results.
$fieldHandle = $this->model->handle; $this->element->setContentFromPost(array( $fieldHandle => 'changedValue' )); // Accessing the value via getContent returns the update value 'changedValue' $changedValue = $this->element->getContent()->fieldHandle; // Accessing the value directly returns the 'originalValue' $originalValue = $this->element->fieldHandle;
Why am I able to successfully update the value for the
getContent() method but not when I access it directly on the model?