The first is pretty simple. I have a form element, (a select element), and I
want to add a class to it, but for some reason it is also adding the class
to the label. I really only want the class for the select drop down box.
here's the code:
$age = $this->addElement('select', 'your_age',
array('label' => $this->translate->_('Select your age'),
'class' => 'small-drop-down'));
$age = $this->getElement('your_age')
->addMultiOptions($this->theAgeRangeOptions)
->setIsArray(false);
$age->setDecorators($firstColDecorators);
this is outputting:
<label for="your_age" class="small-drop-down optional">Select your
age</label>
<select name="your_age" id="your_age" class="small-drop-down">
...
</select>
Is there an easy way around this?
my second question is a bit more complicated, but I basically just want to
create an h3 header for my form, and I was able to add an h3 tag to my form
using the HtmlTag decorator, and prepending it to one of my select box
elements. The only problem is I don't know how to add content inside the
tag. I'm not sure if that makes sense, but here's the code:
$childrenAge = $this->addElement('select', 'ageOfChildren',
array('label' => $this->translate->_('Age'),
'class' => 'small-drop-down'));
$childrenAge = $this->getElement('ageOfChildren')
->addMultiOptions($this->theChildAgeRangeOptions)
->setIsArray(false);
$childrenAge->setDecorators(array(
array('ViewHelper'),
array('Label'),
array('HtmlTag', array(
'tag' => 'li',
'openOnly' => true
)),
array(array('ulTag' => 'HtmlTag'),
array('tag' => 'ul',
'openOnly' => true,
'class' => 'float-left'
)),
array(array('headerTag' => 'HtmlTag'),
array('tag' => 'h3'
)),
array(array('fieldsetTag' => 'HtmlTag'),
array('tag' => 'fieldset',
'openOnly' => true
))
));
$childrenHeader = $childrenAge->getDecorator('headerTag'); //set up
h3 tag for separate styling
$childrenHeader->setOption('placement', 'prepend')
->setOption('content', $this->translate_('Children:'));
//something like this maybe? (this doesn't work though)
the h3 tag renders in front of the select tag but just as <h3
content="Children:"></h3>
Any help would be greatly appreciated.
--
View this message in context:
http://www.nabble.com/two-problems-with-zend-form-tp18096470p18096470.html
Sent from the Zend Framework mailing list archive at Nabble.com.