Skip to main content

Timeline for Trouble with FieldItemList::view

Current License: CC BY-SA 3.0

14 events
when toggle format what by license comment
Nov 9, 2015 at 20:54 comment added Hendrik Yes, that seems to work. Thanks. I think I'm getting the hang of it now …
Nov 9, 2015 at 12:16 comment added 4uk4 Depending on what you are building you can try to add a 'data'-index: $row['email']['data']['#markup']
Nov 9, 2015 at 11:47 comment added Hendrik I've tried the $row['email']['#markup'] line, but it doesn't work …
Nov 8, 2015 at 11:25 comment added Hendrik Good point, and thanks, your examples are indeed helpful. I guess what I was trying to do is to invoke the default formatter for the field, in the same way that the field is displayed when the entity is rendered for viewing. What I wanted to avoid is to implement the formatter in two places (both Formatter class and ListBuilder). What confused me is that there is a view() method that doesn't seem to work.
Nov 8, 2015 at 9:27 history edited 4uk4 CC BY-SA 3.0
added 420 characters in body
Nov 8, 2015 at 9:10 comment added 4uk4 I don't know what you are trying to do, if you render a field, it will go to the entire render system, you can theme this with your own template and so on. I put two alternatives into my answer.
Nov 7, 2015 at 22:54 comment added Hendrik The view() method doesn't work either if I apply it to a node's title field: $row['email'] = $node->title->view();
Nov 7, 2015 at 17:04 history edited 4uk4 CC BY-SA 3.0
added 684 characters in body
Nov 7, 2015 at 16:40 comment added 4uk4 According to documentation the function returns "A render array structure of fields for this entity", but when you check how it is used in core, there are examples, where strings are OK. I'll update my answer.
Nov 7, 2015 at 11:08 comment added Hendrik I don't think ListBuilder expects render arrays in buildRow(). For example, if I supply a number of static strings, such as $row[] = "Hello, World", the output is just fine.
Nov 7, 2015 at 11:06 comment added Hendrik I'm not sure I understand what you're saying. In my code, $entity->email->view() doesn't generate a render array, but an error message.
Nov 7, 2015 at 8:17 comment added 4uk4 That makes sense, the error is before the function returns the render array, in your custom entity is no method to render the entity.
Nov 6, 2015 at 21:42 comment added Hendrik The ID line actually works very well. It's the email line that doesn't.
Nov 6, 2015 at 7:38 history answered 4uk4 CC BY-SA 3.0