Garethp Posted February 14, 2011 Share Posted February 14, 2011 Hey guys, I'm busy creating my own type of form element, just something that extends from Text in order to do some background stuff, and I was wandering how I can use that element to alter the attributes of another element. I was hoping for something like $this->getForm()->getElement('ElementName').setAttr('onClick', 'something'); but I couldn't find something similar to getForm() in the Zend API. Any help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/227585-zend_form_element-setting-another-elements-attribute/ Share on other sites More sharing options...
shlumph Posted March 9, 2011 Share Posted March 9, 2011 You're very close: $this->getForm()->getElement('ElementName')->setAttrib('onClick', 'something'); http://framework.zend.com/apidoc/1.11/Zend_Form/Element/Zend_Form_Element.html#setAttrib Quote Link to comment https://forums.phpfreaks.com/topic/227585-zend_form_element-setting-another-elements-attribute/#findComment-1185032 Share on other sites More sharing options...
Garethp Posted March 22, 2011 Author Share Posted March 22, 2011 Ah, thanks. I ended up just passing the object in through a custom function, and just adding the attribute straight to the object Quote Link to comment https://forums.phpfreaks.com/topic/227585-zend_form_element-setting-another-elements-attribute/#findComment-1190627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.