Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6175841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:59:38+00:00 2026-05-23T23:59:38+00:00

If I have the following simplistic form: <?php class Application_Form_Contact extends Zend_Form { public

  • 0

If I have the following simplistic form:

<?php

class Application_Form_Contact extends Zend_Form
{
    public function init()
    {
        //set the method for the display form to POST
        $this->setMethod('post');

        //create and add e-mail element
        $email = $this    -> createElement('text', 'username')
                              -> setLabel('E-mail:')
                          -> setRequired(true)
                          -> addFilters(array('StringTrim', 'StringToLower'))
                          -> addValidator('EmailAddress')
                          -> addErrorMessage('U dient een geldig e-mail adres in te vullen.');               
        $this->addElement($email);

        //create and add message element
        $message = $this    -> createElement('textarea', 'message')
                            -> setLabel('Bericht:')
                            -> setRequired(true)
                            -> addValidator('StringLength', array(0, 5000))
                            -> addErrorMessage('U dient een bericht in te vullen van maximaal 5000 tekens.');
        $this->addElement($message);

        //submit button
        $this->addElement('submit', 'submit', array(
            'ignore'    => true,
            'label'     => 'Verstuur Bericht'
        ));
    }
}

?>

By default, this will result in a table layout like so:

    <form enctype="application/x-www-form-urlencoded" method="post" action="/contact"><dl class="zend_form"> 
<dt id="username-label"><label for="username" class="required">E-mail:</label></dt> 
<dd id="username-element"> 
<input type="text" name="username" id="username" value=""></dd> 
<dt id="message-label"><label for="message" class="required">Bericht:</label></dt> 
<dd id="message-element"> 
<textarea name="message" id="message" rows="24" cols="80"></textarea></dd> 
<dt id="submit-label">&#160;</dt><dd id="submit-element"> 
<input type="submit" name="submit" id="submit" value="Verstuur Bericht"></dd> 
</dl></form>

Which is quite unnecessary, since some simplistic HTML will result in a form that is more to my liking (as the textarea is under the label while the e-mail input is next to the label):

<form enctype="application/x-www-form-urlencoded" method="post" action="/contact">

    <p>
        <label id="username-label" for="username" class="required">E-mail:</label>
        <input type="text" name="username" id="username" value="" />
    </p>

    <br />  

    <p>
        <label id="message-label" for="message" class="required">Bericht:</label>
        <br />
        <textarea name="message" id="message" rows="24" cols="80"></textarea>
    </p>

    <input type="submit" name="submit" id="submit" value="Verstuur Bericht" />

</form>

Which looks like this: http://jsfiddle.net/qmKYa/ as opposed to http://jsfiddle.net/rudhA/2/.

But how do I get zend not to render any table at all, wrap the first two elements within paragraph tags and add the two new lines for proper spacing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:59:40+00:00Added an answer on May 23, 2026 at 11:59 pm

    First of all, Zend_Form uses decorators to write the form. You can make changes to the existing default decorators but also write and add your own decorators. Check the Zend Reference Guide for examples.

    About the position of labels you can tell the existing decorator to APPEND or PREPEND to the form element.

    Following are couple examples for how you can manipulate existing decorators.

    $element->removeDecorator('DtDdWrapper');
    
    $descriptionDecorator = new Zend_Form_Decorator_Description(array('tag'=>'p','class' => 'description_submit'));
    $descriptionDecorator->setOption('placement','PREPEND');
    $element->addDecorator($descriptionDecorator);
    

    There is also an existing Zend_Form_Decorator_Label class but I don’t have an example ready for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following classes. class A { public: void fun(); } class B: public
Say I have a class, something like the following; class MyClass { public: MyClass();
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
I have following wrapper to help me manage the wcf client lifetime: public class
I have following ViewModel: public IEnumerable<SelectListItem> SelectAdminsInGroup { get; set; } public IEnumerable<SelectListItem> SelectAdminsNotInGroup
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following property in my Model Metadata class: [Required(ErrorMessage = Spent On is
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.