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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:49:40+00:00 2026-06-13T02:49:40+00:00

I wanted to bypass the annoying validation for the Select Element in Zend Framework

  • 0

I wanted to bypass the annoying validation for the Select Element in Zend Framework 2. My requirement is that I have two select drop down boxes where I pass the values from the left select box to right select box and finally when I click the submit button, I post the values from right select box.

So basically the left select box is there to show the values to the user, my problem is that in the left select box as no value is selected it throws this error:

["selectAll"] => array(1) {
      ["isEmpty"] => string(36) "Value is required and can't be empty"
    }

I have seen some old posts from Stackoverflow, where this is possible in Zend Framework 1 like one can disable the validation for the particular select element´

Examples:-

$selectAllElement->setRequired(false);

or

$selectAllElement->removeDecorator('Errors');

which some how these methods are not available in Zend Framework 2. In case if somebody has a solution of how disable the validation for a particular select element, please do share your knowledge, will be hepful for people getting into Zend Framework 2.

EDIT:

In my Form-

    $select = new Element\Select('selectAllElement');
    $select->setAttribute('title', 'Select a Value')
            ->setAttribute('id', 'id');

    $options = array(
        array(
           //Fetching the values from database
            ),
    );

   $select->setAttribute('multiple', 'multiple')
        ->setAttribute('required', false)
        ->setValueOptions($options);

   $this->add($select);

As per request from Sam, I have provided the code how I am adding the select element to my form and setting the attributes.

NOTE: I am not using any FIELDSETS

  • 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-13T02:49:41+00:00Added an answer on June 13, 2026 at 2:49 am

    To clarify this as an answer, using the setRequired()-Method on any Zend\Form\Element only declares if the HTML-Attribute required="(bool)" should be rendered or not.

    If you want to exclude a Field/Element from Validation you need to define this inside your InputFilters setting 'required' => false

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

Sidebar

Related Questions

I wanted to bypass an internal method call and hence have mocked it. The
I wanted to know that if I am doing correctly, regarding retain and release
Assuming you wanted to develop your Controllers so that you use a ViewModel to
I noticed while reading through my code that I have a static member function
If I have a <customErrors> section in my Web.config that says to redirect to
I have a quick question that I'm sure some of you would have an
Wanted to create a fun app with photo. This is the scenario: I have
Just wanted to know if it is better to have Accept-Encoding, gzip in request
Wanted to add an alias for one of the charsets that PayPal may use
I wanted to paint my own version of JButton, so I have overridden the

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.