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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:47:28+00:00 2026-06-02T03:47:28+00:00

After adding elements to my form, I get them rendered in a weird order,

  • 0

After adding elements to my form, I get them rendered in a weird order, getting the submit button before one checkbox. Would appreciate hints on where to check for a quick fix.

class SomeForm extends My_Form {
    public function init() {
        $this->addElements();
        //add a few elements (#1)

        $this->addElements($otherForm->getElements());
        //borrow some elements from another form (#2)

        if ($trueCondition=true) {
            $this->addElements();
            //add one more element which will render at end of form (#3)
        }

        $this->addElements();
        //some more, including submit button (#4)

        parent::init();
        //call My_Form to register custom decorator; culprit?
    }
}

Output:

<inputs from addElements() #1 />
<inputs from addElements() #2 />
<inputs from addElements() #4 />   <-
<inputs from addElements() #3 />   <- mixed up order

All other forms using the custom decorator render elements in the order that they were added. I’m not posting the decorator as it’s pretty messy. Hopefully the error lies elsewhere.

  • 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-02T03:47:30+00:00Added an answer on June 2, 2026 at 3:47 am

    I tried to reproduce your problem using this code:-

    $formA = new Zend_Form();
    $formB = new Zend_Form();
    $formA->addElement(new Zend_Form_Element_Text('formA_text1'));
    $formA->addElement(new Zend_Form_Element_Text('formA_text2'));
    $formB->addElement(new Zend_Form_Element_Text('formB_text1'));
    $formB->addElement(new Zend_Form_Element_Text('formB_text2'));
    
    $formA->addElements($formB->getElements());
    $formA->addElement(new Zend_Form_Element_Text('formA_text3'));
    $formA->addElement(new Zend_Form_Element_Submit('submit'));
    echo $formA->render();
    

    Which gave me this output (decorators removed)

    <input type="text" name="formA_text1" id="formA_text1" value="">
    <input type="text" name="formA_text2" id="formA_text2" value="">
    <input type="text" name="formB_text1" id="formB_text1" value="">
    <input type="text" name="formB_text2" id="formB_text2" value="">
    <input type="text" name="formA_text3" id="formA_text3" value="">
    <input type="submit" name="submit" id="submit" value="submit">
    

    Which is what you are expecting. The only way to reproduce your problem was by setting the order of an element in $formB

    $formA = new Zend_Form();
    $formB = new Zend_Form();
    $formA->addElement(new Zend_Form_Element_Text('formA_text1'));
    $formA->addElement(new Zend_Form_Element_Text('formA_text2'));
    $formB->addElement(new Zend_Form_Element_Text('formB_text1'));
    $formB->addElement(new Zend_Form_Element_Text('formB_text2'));
    $formB->getElement('formB_text2')->setOrder(10);
    $formA->addElements($formB->getElements());
    $formA->addElement(new Zend_Form_Element_Text('formA_text3'));
    $formA->addElement(new Zend_Form_Element_Submit('submit'));
    echo $formA->render();
    

    Which gave me this output

    <input type="text" name="formA_text1" id="formA_text1" value="">
    <input type="text" name="formA_text2" id="formA_text2" value="">
    <input type="text" name="formB_text1" id="formB_text1" value="">
    <input type="text" name="formA_text3" id="formA_text3" value="">
    <input type="submit" name="submit" id="submit" value="submit">
    <input type="text" name="formB_text2" id="formB_text2" value="">
    

    Which is what you are getting. So, it seems to me that you must be setting the order of elements in $otherForm.

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

Sidebar

Related Questions

After adding elements to page using something like this, $('#blah').append('<div id=bugsbunny></div>'); how can I
After adding the /TSAWARE linker flag to one of my projects (Visual Studio 6),
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
My serializable class is not getting read in with objectinputstream after adding static methods
I am trying to create system configuration for my module.After adding system.xml I'm getting
I'm doing a loop through few input elements of 'checkbox' type. After that, I'm
After adding the key value pairs in NSMutableDictionary, when i retrive the key/values from
After adding these settings in web.config for increasing session timeout: <sessionState mode=InProc stateConnectionString=tcpip=127.0.0.1:42424 stateNetworkTimeout=240
After adding <item>170,000</items> to string.xml . It becomes so slow in building workspace, I
I'm using aspxgridview and after adding operation by using RowInserting event and I don't

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.