1. Include the span in the label and turn off escaping.
e.g. $form->addElement('button', 'submit', array('type' => 'submit', 'label'
=> '<span>Send</span>', 'escape' => false));
2. I don't think that's possible without using the ViewScript decorator or
writing a custom one. The regular decorators are not aware of the other
elements in the form.
I'd do it this way:
- strip down the decorators to remove the dt-dd nonsense. I prefer having as
little HTML in the decorators as possible when I render them manually in the
view.
$decors = array('ViewHelper', 'Label', 'Errors');
$form->addElement('text', 'contactFullName', array('label' => 'Naam',
'class' => 'text', 'decorators' => $decors));
$form->addElement('radio', 'contactGender', array('multiOptions' =>
array('m' => 'Mr.', 'f' => 'Ms.'), 'decorators' => $decors));
- render individual decorators in the view along with the markup:
<dt>
<?= $this->form->contactFullName->renderLabel(); ?>
</dt>
<dd>
<?= $this->form->contactGender->renderViewHelper(); ?>
</dd>
<dd>
<?= $this->form->contactFullName->renderViewHelper(); ?>
<?= $this->form->contactFullName->renderErrors(); ?>
</dd>
I personally think this should be the way to go when building the HTML for
the form and should be featured more prominently in the manual. More code
for sure, but you have absolute control over the appearance of the form.
-- Mon
On Wed, Mar 4, 2009 at 6:36 AM, <[email protected]> wrote:
> Hi all,
> I have two questions concerning Zend_Form
>
> 1) Is there an easy way to add a decorator or utilize another method to get
> Zend_Form_Element_Button to insert additional elements inside its tags, like
> so (notice the <span>'s):
> <button type="submit" name="submit"><span>Send</span></button>
>
> 2) Is there an easy way to have a Zend_Form_Element rendered between
> another element and its label. Sort of like so (notice gender radio's in
> between contactFullName label and contactFullName input):
> <dt>
> <label for="contactFullName" class="required">Naam</label>
> </dt>
> <dd>
> <label for="contactGender-m"><input type="radio" name="contactGender"
> id="contactGender-m" value="m">Mr.</label><br>
> <label for="contactGender-f"><input type="radio" name="contactGender"
> id="contactGender-f" value="f">Ms.</label>
> </dd>
> <dd>
> <input type="text" name="contactFullName" id="contactFullName" value=""
> class="text">
> </dd>
>
>
>
> Thank you in advance for your insights.
>
> ------------------------------
> Twee keer zo leuk. Deel foto's terwijl je chat met de nieuwe
> Messenger<http://windowslive.microsoft.nl/WL/Explore/Messenger>
>