Welcome Guest, Not a member yet? Register   Sign In
SOLVED: Form_dropdown: Cannot populate 2 option which has same value
#1

[eluser]tkaw220[/eluser]
Hi,

Although it is very rare case to have 2 options which same one value, but sometime it is needed. In my shopping cart, I used Paypal Express Checkout which accept either credit card or Paypal account payee.

In my dropdown, I would like to be able to populate it as 2 separate options, Credit card and Paypal, with one same value. When I do this in CI, my form return only the last entry. The only workaround I know is to use HTML select.

Is there any tweak where I can tweak the CI form_helper to show 2 entry with same value?

Many thanks.
#2

[eluser]jmadsen[/eluser]
you might give this a try:

"If the array passed as $options is a multidimensional array, form_dropdown() will produce an <optgroup> with the array key as the label."
#3

[eluser]tkaw220[/eluser]
Hi,

Thanks for the reply. But I do not need an <optgroup>, simply <option> to avoid unnecessary confusion.
#4

[eluser]theprodigy[/eluser]
considering form_dropdown takes an associative array, where the keys are the option values, how do you plan on setting two different elements with the same key? Your problem is not what form_dropdown allows or doesn't, but programming logic. PHP, and every other language I know, won't allow you to set two array elements with the same key.
#5

[eluser]tkaw220[/eluser]
Hi theprodigy,

Thank you for the important point. Truly I cannot have 2 items with same key inside an array. Guest I have to do this by using HTML tag and no way else.

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB