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 7857413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:02:36+00:00 2026-06-02T21:02:36+00:00

I’m using Zend Framework and Zend_Form to render my form. But as I found

  • 0

I’m using Zend Framework and Zend_Form to render my form. But as I found it hard to customize it, I decided to print elements individually.

Problem is, I don’t know how to print individual elements inside a display group. I know how to print my display groups (fieldsets) but I need to add something inside it (like a <div class="spacer"></div> to cancel the float:left.

Is there any way to display the group only without its content so I can print them individually myself?

Thank you for your help.

  • 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-06-02T21:02:37+00:00Added an answer on June 2, 2026 at 9:02 pm

    What you are looking for is the ‘ViewScript’ decorator. It allows you to form your html in any way you need. Here is a simple example of how it works:

    The form, a simple search form:

    <?php
    class Application_Form_Search extends Zend_Form
    {
        public function init() {
            // create new element
            $query = $this->createElement('text', 'query');
            // element options
            $query->setLabel('Search Keywords');
            $query->setAttribs(array('placeholder' => 'Query String',
                'size' => 27,
                ));
            // add the element to the form
            $this->addElement($query);
            //build submit button
            $submit = $this->createElement('submit', 'search');
            $submit->setLabel('Search Site');
            $this->addElement($submit);
        }
    }
    

    Next is the ‘partial’ this is the decorator, here is where you build the html how you want it:

    <article class="search">
    <!-- I get the action and method from the form but they were added in the controller -->
        <form action="<?php echo $this->element->getAction() ?>"
              method="<?php echo $this->element->getMethod() ?>">
            <table>
                <tr>
                <!-- renderLabel() renders the Label decorator for the element
                    <th><?php echo $this->element->query->renderLabel() ?></th>
                </tr>
                <tr>
                <!-- renderViewHelper() renders the actual input element, all decorators can be accessed this way -->
                    <td><?php echo $this->element->query->renderViewHelper() ?></td>
                </tr>
                <tr>
                <!-- this line renders the submit element as a whole -->
                    <td><?php echo $this->element->search ?></td>
                </tr>
            </table> 
        </form>
    </article>
    

    and finally the controller code:

    public function preDispatch() {
            //I put this in the preDispatch method because I use it for every action and have it assigned to a placeholder.
            //initiate form
            $searchForm = new Application_Form_Search();
            //set form action
            $searchForm->setAction('/index/display');
            //set label for submit button
            $searchForm->search->setLabel('Search Collection');
            //I add the decorator partial here. The partial .phtml lives under /views/scripts
            $searchForm->setDecorators(array(
                array('ViewScript', array(
                        'viewScript' => '_searchForm.phtml'
                ))
            ));
            //assign the search form to the layout place holder
            //substitute $this->view->form = $form; for a normal action/view
            $this->_helper->layout()->search = $searchForm;
        }
    

    display this form in your view script with the normal <?php $this->form ?>.

    You can use this method for any form you want to build with Zend_Form. So adding any element to your own fieldset would be simple.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

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.