Reputation: 227
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
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
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