![](/img/trans.png)
[英]Zend 2 framework form helper method openTag is converting my action to htmlspecialchars
[英]Zend\Form openTag() method not including all attributes
<?php
$form->setAttribute('action', $this->url('customer', array('action' => 'index')));
$form->setAttribute('ng-submit', 'validateForm()');
$form->prepare();
var_dump($form->getAttributes());
echo $this->form()->openTag($form);
?>
好了,正如您所看到的,我正在設置一些表單屬性,然后使用var_dump($form->getAttributes());
將其轉儲var_dump($form->getAttributes());
結果如下:
array (size=4)
'method' => string 'get' (length=3)
'name' => string 'searchCustomerForm' (length=18)
'action' => string '/customer' (length=9)
'ng-submit' => string 'validateForm()' (length=4)
但結果form
標記為:
<form id="searchCustomerForm" action="/customer" name="searchCustomerForm" method="get" class="ng-pristine ng-valid">
ng-submit屬性丟失!!
如何設置form
屬性?
Zend\\Form
僅允許有效的HTML屬性。 為了解決這個問題,您可以使用data-ng-submit
(至少在HTML5中有效),或擴展表單幫助程序以覆蓋有效的屬性列表或跳過屬性驗證的某些元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.