简体   繁体   English

Zend \\ Form openTag()方法不包括所有属性

[英]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);
?>

Well, as you can see I'm setting some form attributes ans the dumping them with var_dump($form->getAttributes()); 好了,正如您所看到的,我正在设置一些表单属性,然后使用var_dump($form->getAttributes());将其转储var_dump($form->getAttributes()); and here is the result: 结果如下:

array (size=4)
    'method' => string 'get' (length=3)
    'name' => string 'searchCustomerForm' (length=18)
    'action' => string '/customer' (length=9)
    'ng-submit' => string 'validateForm()' (length=4)

but the result form tag is : 但结果form标记为:

<form id="searchCustomerForm" action="/customer" name="searchCustomerForm" method="get" class="ng-pristine ng-valid">  

the ng-submit attribute is missing!! ng-submit属性丢失!!

How Can I set form attributes? 如何设置form属性?

Zend\\Form only allows valid HTML attributes. Zend\\Form仅允许有效的HTML属性。 To get around this you can either use data-ng-submit (which is valid in HTML5 at least), or extend the form helper to override either the valid attribute list or skip some elements of the attribute validation. 为了解决这个问题,您可以使用data-ng-submit (至少在HTML5中有效),或扩展表单帮助程序以覆盖有效的属性列表或跳过属性验证的某些元素。

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

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