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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:15:19+00:00 2026-05-14T22:15:19+00:00

I am using an XML config file to tell Zend_Form what elements I want.

  • 0

I am using an XML config file to tell Zend_Form what elements I want. I would like to have a <select> element, but I am unsure as to how to add <option> tags using the XML syntax.

Sure I am missing something pretty basic.

Ben

  • 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-14T22:15:20+00:00Added an answer on May 14, 2026 at 10:15 pm

    Programmatic forms in the ZF only support the parameters type, name and options (not in the meaning of choices but of element settings, like required or label) for the form elements. It is assumed that multiple values will be set dynamically, e.g:

    $formConfig = new Zend_Config_Xml('/path/to/form.xml');
    $form = new Zend_Form($formConfig);
    $form->getElement('myselect')->setMultiOptions($arrayOfOptions);
    

    Of course there’s the possibility of actually setting the element options in the XML file using your own name convention (will be ignored by Zend_Form) and then load them from there instead of having the hardcoded or retrieved at runtime, for instance:

    <?xml version="1.0" encoding="UTF-8"?>
    <form>
        <user>
            <example>
                <name>mysampleform</name>
            <method>post</method>
            <elements>
            <myselect>
                    <type>select</type>
                    <name>myselect</name>
                    <multioptions> <!-- custom tag -->
                        <option value="First">1</option>
                        <option value="Second">2</option>
                        <option value="Third">3</option>
                    </multioptions>
                    <options>
                        <label>Choose an option:</label>                        
                        <required>true</required>
                    </options>
                </myselect>
                <submit>
                <type>submit</type>
                <options>
                    <value>Submit</value>
                </options>
                </submit>   
            </elements>    
        </example>
    </user>
    

    $formConfig = new Zend_Config_Xml('/path/to/form.xml');
    $form = new Zend_Form($formConfig);
    $form->getElement('myselect')->setMultiOptions(
        $formConfig->user->example->elements->myselect->multioptions->toArray()
    );
    

    Yet it doesn’t seem to be more effective than just having those options stored somewhere else.

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

Sidebar

Related Questions

I'm using an XML config file to populate my navigation using Zend_Navigation. I have
It's not a problem to set cron intervals using xml-config file, but it'll be
Hey. I want to have a config.xml file for settings in a Python web
I'm using XML for a config file in PHP (Using SimpleXML), in creating the
Been using XML for ages now for data storage & transfer, but have never
I am currently using xml as a config file for my silverlight application. I
All, I have a config xml file in the following format: <?xml version=1.0?> <configdata>
This is my first time using an XML config file. In the solution explorer
I have successfully setup castle windsor using an xml configuration file and everything works
I'm using an XML based .config file for storing some records. My XML is

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.