Filter fields - Indirect modification of overloaded property

I’m having issues with filtering fields.

I do:

public function filterFields($fields, $context = null) {
    if ($this->status === 'sent') {
        $fields->subscriber_category->readOnly = true; // where subscriber_category is a relation field
    }
}

And I get this error:

Indirect modification of overloaded property October\Rain\Element\ElementHolder::$subscriber_category has no effect

I checked the documentation here:
Field Dependencies - October CMS - 3.x

Any ideas of what I’m doing wrong?

Just add it to the if statement to check that it’s there. Likely another widget using the model is looking for a field that isn’t there.

public function filterFields($fields, $context = null) {
    if ($this->status === 'sent' && isset($fields->subscriber_category) {
        $fields->subscriber_category->readOnly = true; // where subscriber_category is a relation field
    }
}
2 Likes