1
<?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());,结果如下:

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属性?

4

1 回答 1

1

Zend\Form只允许有效的 HTML 属性。为了解决这个问题,您可以使用data-ng-submit(至少在 HTML5 中有效),或者扩展表单助手以覆盖有效属性列表或跳过属性验证的某些元素。

于 2015-11-04T17:42:07.047 回答