0
votes

I have Zend_Form with button type element. i don't how to use onclick type from zend_form.

Index.phtml

Search

Zend_Form

$Search = new Zend_Form_Element_Submit('Search');
    $Search->setAttrib('ID', 'searchbutton');
    $Search->setDecorators(array('ViewHelper'));

Here using this zend form how to perform the onclick action using search button.could you please any one help on this?

Thanks for advice!

1

1 Answers

1
votes

Hey you would have to do something like this

$Search = new Zend_Form_Element_Submit('Search');
$Search->setAttrib('ID', 'searchbutton');
$Search->setDecorators(array('ViewHelper'));

$form = new Zend_Form('FormExample');
$form->setAction('destination.php');
$form->setMethod('POST');
$form->addElement($Search);
$form->setView(new Zend_View());
print($form);

If you have other elements than the $Search you just have to addElements as an array, like this:

$form->addElements([$Search,$Element1, $Element2]);