I'm using a migration script to clear out the values for a field on one of my entries. The field is an Entry Field and is not required.

So I do this:

$product->components = [];

But I get this error:

Argument 1 passed to craft\fields\BaseRelationField::_all() must implement interface craft\elements\db\ElementQueryInterface, array given, called in /var/www/html/vendor/craftcms/cms/src/fields/BaseRelationField.php on line 382

I can clear out other fields, even entry fields, just fine. But this particular one gives me this error every time.

I've also tried the following:

$product->components = null;


$product->components = false;

Any ideas?

1 Answer 1


I figured it out. I'm not sure understand the why of it. But here is the how:

$product->setFieldValue('components', []);

I guess setFieldValue() does some other stuff in it that the magic methods do not.

The more you know! :)

  • 1
    What the freaking heck. That worked. Thanks!
    – Fred
    Commented Jun 27, 2019 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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