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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:59:54+00:00 2026-06-12T21:59:54+00:00

I´m developing an application using Zend Framework 2 and I´m using two select multiple

  • 0

I´m developing an application using Zend Framework 2 and I´m using two select multiple boxes. The first is populated with data from the data base, the second is empty.

I intend to set the disabled attribute as “disabled” in the first option of both selects.
This way the first options will be unusable and un-clickable. Therefor a user will not be able to pass those first options from one select to the other while using the add/remove buttons.

Select 1

   <select id="AttributesId" multiple="multiple" size="7" title="Select an Attribute" name="idAttributes[]">
   <option value="0">Please Select an Attribute</option>
    <option value="1"> Attribute 1</option>
    <option value="2"> Attribute 2</option>
   </select>

Select 2

<select id="SelectedAttributesId" multiple="multiple" size="7" title="Selected Attributes" name="selectedAttributes[]">
<option value="0">Current Selection</option>
</select>

The php code that generates both selects on ZF2 is:

(…)

public function __construct ($em = null)
    {
        parent::__construct("typeset");
        $this->setAttribute("method", "post")
            ->setAttribute("class", "contact-form");

        if(null !== $em)
        {
            $this->setEntityManager($em);
        }

        $em = $this->getEntityManager();
        $query = $em->createQuery("SELECT a.idAttribute, a.internalName FROM ProductCatalog\Entity\Attribute\Attribute a ORDER BY a.internalName ASC");
        $attributes = $query->getResult();

        $select = new Element\Select('idAttributes');
        $select->setAttribute('title', 'Select an Attribute')
                ->setAttribute('size', 7)
                ->setAttribute('multiple', 'multiple')
                ->setAttribute('id', 'AttributesId');

        $selected = new Element\Select('selectedAttributes');
        $selected->setAttribute('title', 'Selected Attributes')
               ->setAttribute('size', 7)
               ->setAttribute('multiple', 'multiple')
               ->setAttribute('id', 'SelectedAttributesId');

        $labelIdAttributes = 'Attributes List: ';
        $labelSelectedAttributes = 'Selected Attributes List: ';

        $options[0] = 'Please Select an Attribute';

// this followin line doesn´t work but you can get an idea of what I need with it
//$options[0]->setAttribute(‘deselect’, ‘deselect’);

        foreach ($attributes as $key => $value)
        {
            $options[$value['idAttribute']] = $value['internalName'];
        }

        $selectedOptions[0] = 'Current Selection';



        $select->setLabel($labelIdAttributes)
               ->setValueOptions($options);


        $selected->setLabel($labelSelectedAttributes)
                ->setValueOptions($selectedOptions);


        $this->add($select);
        $this->add($selected);

(...)
  • 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-12T21:59:55+00:00Added an answer on June 12, 2026 at 9:59 pm

    If I remember correctly you need to format the options array slightly differently:

    $options = array(
        array('value' => '0', 'label' => ' Please Select an Attribute', 'disabled' => 'disabled'),
        array('value' => '1', 'label' => ' Attribute 1'),
        array('value' => '2', 'label' => ' Attribute 2')
    );
    

    Disabled is one of the valid attributes.

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

Sidebar

Related Questions

I am developing a web application using zend framework. For select statements I have
I've been developing a PHP application using the Zend framework for awhile on a
I am developing an application using Zend Framework 1.11.10. I have used this article
I am developing the application of login using facebook in Zend Framework. I done
I am developing an application to manage a law office using zend framework 1.10,PHP
I am developing a web application with Zend Framework, and I am using JQuery
I was developing an application using Entity Framework and storing data in a .mdf
I'm developing a web application using Zend Framework 2 which will be made of
I'm developing an application using the WAF (WPF Application Framework) which is based on
Im trying to learn how to set up a Zend framework web application from

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.