I am trying to process a text field inside a Matrix field.

In the controller I have this to get posted params:


If I want to process a custom text field, I can do it easily with


which $result is exactly the text field value.

but if I have this text field in Matrix field, if I do this:


I get a craft\elements\db\MatrixBlockQuery object which I don't know how I can fetch text value from this object.


You have to loop the Matrix field first, something like this:

foreach($entry->matrixHandle->all() as $block) {
   echo $block->fieldHandle;
  • thanks @gioppe i should have used one() or all() because it returns craft\elements\db\MatrixBlockQuery and i had to get result first
    – user9975
    Feb 4 '20 at 12:41

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.