Hi Mon,


Thank you for your reply.

1) So I can turn of escaping? Great! I tried including it in the label, and 
indeed it escaped the characters. This was just what I needed to know. Thanks!

2) Hmmm, so I guess I'm stuck to a ViewScript decorator then huh? I was trying 
to avoid it, for the reason that I would preferably like to have the Form code 
in one place. Nonetheless, the example you have given is a very valuable one. I 
couldn't figure out how to do it in a ViewScript when I experimented with it 
earlier. I wasn't aware of the render[*****] methods. But this demonstrates 
things perfectly. Much obliged!

Cheers

Date: Wed, 4 Mar 2009 11:18:46 +0800
From: mon...@gmail.com
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Zend_Form_Element_Button question and a general       
Zend_Form question

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,  <fire-eyed-...@hotmail.com> 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



_________________________________________________________________
Blijf altijd op de hoogte van wat jouw vrienden doen
http://home.live.com

Reply via email to