I have a content type with a multiple referenced field and I need to iterate trough each item and display the item information in a table but I don't know and didn't find a way to access the content field information like the value of a specific field.
Example: I have a content type called Task and in Task I have multiple Entity Reference to Worker content type, Worker has title, name and phone. How can I iterate each worker and display the information in a table?
What I want to do is to override node--task.html.twig to do something like this:
Assuming that we have a field_workers field in task content type.
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Phone
</th>
</tr>
</thead>
<tbody>
{% for worker in content.field_workers %}
<tr>
<td>
{{worker.field_name.value}}
</td>
<td>
{{worker.field_phone.value}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
Is it possible? Thank you!
worker.entity
defined in the loop? If so it's probably just a matter of using{{worker.entity.field_name.value}}
etc