1
$blocks = MatrixBlock::find()->relatedTo($entry)->all();

The above returns the correct blocks but all fields are returned as NULL.

I've read over at GitHub that we need to specify a fieldId param but can't seem to figure out how. The below e.g. doesn't work:

$blocks = MatrixBlock::find()->relatedTo($entry)->fieldId([33])->all();

Help anyone?

  • Is your field id correct? You need to insert an id and not an array – Robin Schambach Jun 21 '18 at 5:00
  • @RobinSchambach Ah yes my field id was wrong... I was adding the field id of the matrix block. The right ID to add is the Matrix field id as defined in the Fields section. Thank you! – biko Jun 21 '18 at 5:25
1

The right Field ID to add is the Matrix field id as defined in the Fields section. Do not use the ids of the matrix block fields.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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