简体   繁体   中英

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()); 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 id="searchCustomerForm" action="/customer" name="searchCustomerForm" method="get" class="ng-pristine ng-valid">  

the ng-submit attribute is missing!!

How Can I set form attributes?

Zend\\Form only allows valid HTML attributes. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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