开发者

Remove an option from a Zend Radio Form Element

开发者 https://www.devze.com 2023-04-09 14:52 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消