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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:52:03+00:00 2026-05-16T06:52:03+00:00

Using the form helper in CakePHP 1.3, I’m trying to display a list (drop-down

  • 0

Using the form helper in CakePHP 1.3, I’m trying to display a list (drop-down list) which contains several duplicated value fields (in <option> tag of course), but Cake does not seem to want to let me do it, and outputs only the first occurrence of each value.

For instance, here’s the ‘options’ array of the $form->input:

array(
    0 => 'description 0',
    0 => 'description 1',
    0 => 'description 2',
    1 => 'description 3'
);

Which will output something like:

<select>
    <option value="0">description 0</option>
    <option value="1">description 3</option>
</select>

And I’m looking for this result:

<select>
    <option value="0">description 0</option>
    <option value="0">description 1</option>
    <option value="0">description 2</option>
    <option value="1">description 3</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-05-16T06:52:04+00:00Added an answer on May 16, 2026 at 6:52 am

    So as feared the problem was deeper than I first thought , and it was caused by PHP which does not (obviously) allow duplicate keys.

    So here’s my solution (if anyone’s interested in):

    1. Create a new helper extending the FormHelper
    2. Copy the original function __selectOptions() from the form helper into your new helper
    3. Just change this line:
      foreach ($elements as $name => $title) {
      by :
      foreach ($elements as $title => $name) {
    4. Done!

    It’s not the best solution as if you want to update your cakephp to the latest version after doing that, you have to copy/paste the function again, and do the same trick.

    How to use it:

    1. Declare your options array the other way around : array('description' => 'key);
    2. In your view, instead of doing $form->input, just do $yourhelper->input

    Nicolas.

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

Sidebar

Related Questions

To avoid reinventing the wheel, I am generating a form using CakePHP's form helper,
I'm trying to create a form using Cakephp's FormHelper class. The form needs to
I am, using a cakephp form helper to upload images to my server. The
Using CakePHP's form helper to generate a checkbox is easy enough; to use the
Using CakePHP 1.3 , I post a form which correctly fills in $this->data .
$x=array('a','b','c'); echo form::dropdown('test', $x, 'b'); I'm using the Kohana form helper to build forms,
i am using form authentication for my website which is written in ASP.Net, but
I am trying to create a custom authentication scheme in ASP.NET MVC using form
Using Zend_Form, how would I create form elements like this: <input type=text name=element[1] value=
I'm trying to upload a file to my server using the CakePHP file upload

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.