zend-form-element

How to add CSS classes to Zend_Form_Element_Select option

六眼飞鱼酱① 提交于 2019-12-07 16:50:23
问题 I'm trying to add a CSS class to a Zend_Form_Element_Select option, but I just can't find a way to do it. The desired output would be something like this: <select name="hey" id="hey"> <option value="value1" style="parent">label1</option> <option value="value2" style="sibling">sublabel1</option> <option value="value3" style="sibling">sublabel2</option> <option value="value4" style="parent">label2</option> <option value="value5" style="sibling">sublabel3</option> <option value="value6" style=

How to render some html in Zend form?

蓝咒 提交于 2019-12-06 22:09:44
In my form i need this: <li class ="af_title"><div>Contact form</div></li> I understand that if I need for example a text field - then I'd just create Zend_Form_Element_Text and wrap HtmlTag decorator around it - right? questions: 1) how would I generate div form element so I can wrap decorator around it? 2) mmm. - how would I set content of said element to be "Contact form"? Thanks:) To wrap your Contact form around div which is inside <li class ="af_title"> you can do as follows: $yourForm = new YourForm(); $yourForm->addDecorator(array('div' => 'HtmlTag'), array('tag' => 'div')); $yourForm-

Zend Forms - Element ID modification to allow re-use

廉价感情. 提交于 2019-12-06 05:19:55
I have a Zend_Form object that I want to re-use several times in one page. The problem I'm having is that each time it's rendered it has the same element IDs. I've been unable to find a method for giving all the IDs a unique prefix or suffix each time I render the form. Complete Solution Subclass Zend_Form : class My_Form extends Zend_Form { protected $_idSuffix = null; /** * Set form and element ID suffix * * @param string $suffix * @return My_Form */ public function setIdSuffix($suffix) { $this->_idSuffix = $suffix; return $this; } /** * Render form * * @param Zend_View_Interface $view *

How to add CSS classes to Zend_Form_Element_Select option

岁酱吖の 提交于 2019-12-05 20:16:11
I'm trying to add a CSS class to a Zend_Form_Element_Select option, but I just can't find a way to do it. The desired output would be something like this: <select name="hey" id="hey"> <option value="value1" style="parent">label1</option> <option value="value2" style="sibling">sublabel1</option> <option value="value3" style="sibling">sublabel2</option> <option value="value4" style="parent">label2</option> <option value="value5" style="sibling">sublabel3</option> <option value="value6" style="sibling">sublabel4</option> </select> But I'm getting this: <select name="hey" id="hey"> <option value=

Zend Form Element with Javascript - Decorator, View Helper or View Script?

一个人想着一个人 提交于 2019-12-05 15:30:45
I want to add some javacsript to a Zend_Form_Element_Text . At first I thought a decorator would be the best way to do it, but since it is just a script (the markup doesn't change) then maybe a view helper is better? or a view script? It seems like they are all for the same purpose (regarding a form element). The javascript I want to add is not an event (e.g. change, click, etc.). I can add it easily with headScript() but I want to make it re-usable , that's why I thought about a decorator/view helper. I'm just not clear about the difference between them. What is the best practice in this case

Override Separator on Zend_Form Radio Elements When Using a ViewScript Decorator

余生颓废 提交于 2019-12-04 19:39:30
I am using ViewScripts to decorate my form elements. With radio elements, the separator can normally be overridden, but the override is being ignored when I use the ViewScript. When I use the below call and ViewScript, the radio elements are separated by a '<br />' rather than the space I've specified. If leave the default decorators, the override works. $this->addElement('radio', 'active', array( 'disableLoadDefaultDecorators' => true, 'decorators' => array(array('ViewScript', array('viewScript' => 'form/multi.phtml'))), 'label' => 'Active', 'required' => true, 'multiOptions' => array('1' =>

Customize zend_form Captcha output?

折月煮酒 提交于 2019-12-04 02:42:46
I'm using captcha in my zend_form. $captcha_element = new Zend_Form_Element_Captcha( 'captcha', array('label' => 'Write the chars to the field', 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'font' => DOC_ROOT . '/data/fonts/Vera.ttf', 'imgDir' => $imagedir, 'imgUrl' => $umageurl ) ) ); This generates: <dt id="captcha-input-label"> <label for="captcha-input" class="required">Write the chars to the field</label> </dt> <dd id="captcha-element"> <img width="200" height="50" alt="" src="http://sitename.com/captcha/09dd951939c6cdf7fa28f2b7d322ea95.png"> <input type=

Zend Form: Checkbox element displays as hidden field?

我只是一个虾纸丫 提交于 2019-12-04 01:48:25
I would like to add a simple check box to my form: $element = new Zend_Form_Element_Checkbox('dont'); $element->setDescription('Check this box if you don\'t want to do this action.'); $form->addElement($element); However, this is what the html looks like: <dt id="dont-label"> </dt> <dd id="dont-element"> <input type="hidden" name="dontAttach" value="0"> <input type="checkbox" name="dontAttach" id="dontAttach" value="1"> <p class="description">Don't attach a bulletin. I only want to send an email.</p> </dd> The problem with this is that I'm using jQuery to hide all the DT/DDs that have a label

Zend_Form_Element_MultiSelect element definition

隐身守侯 提交于 2019-12-03 22:38:28
问题 Is there any way to define wich options in Zend_Form_Element_MultiSelect would be selected by default?? 回答1: $element = new Zend_Form_Element_MultiCheckbox('foo', array( 'multiOptions' => array( 'foo' => 'Foo Option', 'bar' => 'Bar Option', 'baz' => 'Baz Option', 'bat' => 'Bat Option', ); )); $element->setValue(array('bar', 'bat')); http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.multiCheckbox 来源: https://stackoverflow.com/questions/3488057/zend

How to remove a validator from a Form Element / Form Element ValidatorChain in Zend Framework 2?

99封情书 提交于 2019-12-03 21:18:10
问题 I read this question on SO: "how to disable inArray validator forms in zend framework2" and was trying to find it out, but couldn't find any way to detach/remove the InArray Validator. But InArray is just a validator. So how can remove a validator from the validator list of a form element? I can get the validators: $myElement = $form->getInputFilter()->get('city'); $validatorChain = $cityElement->getValidatorChain(); $validators = $validatorChain->getValidators(); and maybe can then unset the