I have a collection of items passed from my controller to my twig template called qualifications. I then loop through each object in the collection and print it to a row in the table. Every respective row has an "Edit" button, which should pass that object's values to a javascript function. Here is my code:
{%for qualification in qualifications%}
<tr id="qualification_{{qualification.id}}">
<td>{{qualification.name}}</td>
<td>{{qualification.saqaId}}</td>
<td>{{qualification.qualificationType}}</td>
<td>{%if (qualification.course is null) %} - {%else%} {{qualification.course.name}} {%endif%}</td>
<td>0</td>
<td><a class="button btn-primary btn-xs" onclick="setForm({{qualification|json_encode(constant('JSON_PRETTY_PRINT'))}});">Edit</a></td>
</tr>
{%endfor%}
I am getting the information in the table row as expected, but when looking at the HTML on the Edit button I just see onclick="setForm({});". I have tried with and without the raw, I have also tried {{qualification|json_encode(constant('JSON_PRETTY_PRINT'))}} but all return blank.
On a similar, but not related note. I have been having other issues with TWIG as well. {{dump()}} just loads a while and then gives a blank page with an unspecified 500 error. have tried activating the twig debug in services.xml and config.yml with what documentation I could find, but to no avail. This, however is not my primary concern, my primary concern is json_encode returning an empty result.
And help or advice on this would be greatly appreciated as I have run into a wall.
json_decode?