I am passing an associative array from my controller to my view and then iterating it on the template engine
<tbody class="text-center">
{% for inv in inv_list %}
<tr>
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="{{ inv['supplier_invoice_number'] }}"></td>
<td>{{ inv['contract_id'] }}</td>
<td>{{ inv['supplier_invoice_number'] }}</td>
<td>{{ inv['final_payable_amount'] }}</td>
<td>{{ inv['markup_value'] }}</td>
<td>{{ inv['markup_type'] }}</td>
<td>{{ inv['buyer_price'] }}</td>
<td><button class="btn btn-success" onclick="generateInvoice('{{ inv }}')">Invoice</button></td>
<td><button class="btn btn-success">Invoice Email</button></td>
</tr>
{% endfor %}
</tbody>
Like above .I want to pass the value of the object in the onclick method ,but its giving an error
Array to string conversion
.How to solve this .Please help me out
This Error
Array to string conversionmeans tat you try to print an array. In your caseinvis an array. I think that you need only to pass the id likeonclick="generateInvoice('{{ inv['contract_id'] }}')"or a other unique value from your inc array.