简体   繁体   English

如何在phalcon volt模板引擎中将数组传递给js按钮单击

[英]How to pass an array to js button click in phalcon volt template engine

I am passing an associative array from my controller to my view and then iterating it on the template engine我将一个关联数组从我的 controller 传递到我的视图,然后在模板引擎上对其进行迭代

 <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像上面一样。我想在 onclick 方法中传递 object 的值,但它给出了一个错误

Array to string conversion数组到字符串的转换

.How to solve this.Please help me out .如何解决这个问题。请帮帮我

This Error Array to string conversion means tat you try to print an array.这个错误Array to string conversion意味着你尝试打印一个数组。 In your case inv is an array.在您的情况下, inv是一个数组。 I think that you need only to pass the id like onclick="generateInvoice('{{ inv['contract_id'] }}')" or a other unique value from your inc array.我认为您只需要传递像onclick="generateInvoice('{{ inv['contract_id'] }}')"这样的 id 或您的 inc 数组中的其他唯一值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM