开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜