Delta
Delta

Reputation: 227

Implement onkeyup() function in Zend forms to add an element

I want to implement a sort of onkeyup() function in Zend form to add an element. I don't know the syntax.

This is my code:

$this->addElement('text', 'userid', array(
    'label'      => '',
    'required'   => true,
    'filters'    => array('StringTrim'),
    'style'    => array('width:212px'),

Upvotes: 2

Views: 436

Answers (2)

alwaysLearn
alwaysLearn

Reputation: 6950

you have to use attribs options to add extra attributes

Try This

$this->addElement('text', 'userid', array(
'label'      => '',
'required'   => true,
'filters'    => array('StringTrim'),
'style'      => array('width:212px'),  
'attribs' => array('onkeyup'=>'handler()')

you can also use setAttrib

Upvotes: 1

user2334807
user2334807

Reputation:

Use the following code:

$this->addElement('text', 'userid', array(
    'label'      => '',
    'required'   => true,
    'filters'    => array('StringTrim'),
    'style'    => array('width:212px'),
    'attribs'    => array('onkeyup'=>'jsFunction();')
));

OR you can use below code:

$element = $this->addElement('text', 'userid', array(
        'label'      => '',
        'required'   => true,
        'filters'    => array('StringTrim'),
        'style'    => array('width:212px'),
    ));

$element->setAttrib('onkeyup', 'jsFunction();');

Upvotes: 1

Related Questions