Remove an option from a Zend Radio Form Element
An easy question. I have a Zend_Form_Element_Radio element in my form with multioptions. I'd like to remove an option in my controller.
I've found how to disable an option ...
开发者_如何学运维$element = $membershipForm->getElement('myElement');
$element->setAttrib('disable', array('value'));
But how can I remove it? With removing some decorators? Or is there a better way?
Thanks in advance!
Since every FormElement has a unique identifier it is pretty simply to remove it.
$form->removeElement($id); // most likely when removing from within the controller
$this->removeElement($id); // when removing from within the form object
$selectElement->removeMultiOption('value'); // To remove a single option from a select
That's all you need ;)
精彩评论