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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:23:12+00:00 2026-06-17T13:23:12+00:00

Why the choice of an empty item in Zend\Form\Element\Select is selected also the zero

  • 0

Why the choice of an empty item in Zend\Form\Element\Select is selected also the zero element?

In form class:

$this->add(array(
'type' => 'Zend\Form\Element\Select',
    'name' => 'active',
    'options' => array(
        'label' => _('Active'),
        'empty_option' => '',
        'value_options' => array(
            1 => 'Yes',
            0 => 'No',
    ),
 ),
));

In controller:

$searchForm->setData( $request->getPost() );

html, generated ZF2:

<select name="active">
    <option value="" selected="selected"></option>
    <option value="1">Yes</option>
    <option value="0" selected="selected">No</option>
</select>
  • 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-17T13:23:14+00:00Added an answer on June 17, 2026 at 1:23 pm

    This pretty much has to do with how PHP interprets '', 0 and null in array()-context. I’m not sure if this can even be worked out giving the current implementation, but i suggest you open an issue on github about this.

    This could be considered a bug.

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

Sidebar

Related Questions

I'm trying to customize Symfony2 form rendering to add a class to every select
So, in a form I have multiple choice and therefore an array of answers
I am using multiple choice ListView items. The user can select multiple items. So
I am trying to write simple Binary Search tree class (BST). When I add
Possible Duplicate: Conflicting boolean values of an empty JavaScript array What is the rationale
I have a model in Django that looks like this: class Project(models.Model): name =
I'm trying to force a form field to be required based on a choice
Python's module 'random' has a function random.choice random.choice(seq) Return a random element from the
I'm setting up dynamic pulldowns: the choice on select#category informs the contents of select#subcat.
i have ajax script for select some infomrations. If the user selects a choice,

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.