user6420577
user6420577

Reputation: 225

Zend Form create button link

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!

Upvotes: 0

Views: 353

Answers (1)

Jefferson Guardia
Jefferson Guardia

Reputation: 11

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]);

Upvotes: 1

Related Questions