-2

I have a view grid that has custom actions to perform based on selected grid row. To read the view fields from the grid dpm-ed the below command:

dpm($this->view->result);

The above command returns:

enter image description here

I am trying to specifically read the "field_comment_id_comment_field_data_nid" and I get null every time:

 dpm($this->view->result[0]->field_comment_id_comment_field_data_nid);

Update: I modified the dpm and I see the value correctly. Unsure of how to loop through the result array. still trying.

4
  • ResultRow doesn’t have a get method. The output says field_comment_id_comment_field_data_nid is a public property of the object so you can access it directly
    – Clive
    Commented Nov 30, 2021 at 17:53
  • I tried the below code: dpm($this->view->result->field_comment_id_comment_field_data_nid->Value) to read the value directly and I get null
    – chaydru
    Commented Nov 30, 2021 at 17:58
  • 1
    You need to pay a bit more attention to the debug output - $this->view->result is an array
    – Clive
    Commented Nov 30, 2021 at 18:19
  • can i get some more help? I'm still seeing null on my end :( newbie here..
    – chaydru
    Commented Nov 30, 2021 at 19:10

1 Answer 1

0

Alright. Below solution works:

foreach($this->view->result as $result)
  dpm($result->field_comment_id_comment_field_data_nid);
}

thanks @clive for pointing on the array thing.

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