Select Tag with a few options containing multiple values in cakePHP

I am using cakePHP 1.26.

I am designing a Select Tag with a few Options, and each of the options will contain multiple values.

Yet, there is not only one way to do it:

Method 1:

<select name=""> <option value="[0,1,2,3]">Option one</option> </select>

Method 2:

<select name=""> <option value="{foo:'bar',one:'two'}">Option two</option> </select>

Please advise which of the methods is the best to work with cakePHP.


If you're getting the values from the db, use the find('list') construct. There's a good working example halfway down this page:

How you do it is up to you really. I use an array where the key is the value I want to process and the value is what I want the user to see. Neither of your examples look valid to me, but I'm a bit rusty on the finer points of HTML as I usually do that sort of thing with PHP or JS.

Category:cakephp Time:2010-07-14 Views:0

Related post

  • How to disable select tag options through jQuery? Need help 2010-08-10

    I have a query regarding Select tags option. plz any one solve through jQuery. Suppose i have two select tags, in the first select tags i have options of Languages and script and in the second tag of select i have option regarding languages & scr

  • What is the fastest way to create a select tag with 5000 options in IE6? 2010-12-27

    Usability aside: What is the fastest way to create a select tag with 5'000 option elements in IE6 from JavaScript? --------------Solutions------------- Short test: Collecting a innerHTML-string first and inject it to the document: around 300ms append

  • Parse a select tag with regex (php) 2009-03-31

    I would like to scan a specific select tag for all the option-tags values and content in PHP. So that from this <select> <option value="donald">duck</option> <option value="david">moose</option> </select> <selec

  • Set a dynamic value to "value" attribute of a html:select tag 2011-12-24

    How can I set a dynamic value to the value attribute of a Struts html:select tag from bean:write to highlight the selection? --------------Solutions------------- The html select tag automatically selects the option that has a value equal to the prope

  • Can an option in SELECT tag carry multiple values? 2010-07-14

    I got a select tag with some options in a HTML form: (the data will be collected and processed using PHP) Testing: <SELECT NAME="Testing"> <OPTION VALUE="1"> One <OPTION VALUE="2"> Two <OPTION VALUE="3"> Three </SELECT>

  • Need to speed up jQuery for selecting options lines in multiple selection tag 2011-11-19

    I need to speed up this jQuery line for select tag with possilbly several thousand option tags. Is there anything faster than the following jQuery line? Maybe javascript? I'm even looking for a replacement b/c code is slow and unresponsive if used in

  • Spring MVC form:select Tag, multiple selections not binding correctly? 2009-04-01

    I am trying to create a form to edit an existing database row. I am using the Spring MVC form tag to auto bind the html to a form backing object. The row has a many to many relationship with another table, which I am trying to represent with a multip

  • Creating a select tag with options in JQUERY 2009-05-18

    Is it possible to create a select tag with options in JQuery. $("<select id="jSelect"> <option value="1">String</option> <option value="2">Number</option> <option value="3">Date</option> </select>").app

  • reading option of three select tags with same name 2009-07-14

    How can i have three or more select tags with same names(as in my program, the select tags are being generated dynamically), and select independently what option was selected. I have a loop, where my php reads a sql table, and for each row, it creats

  • Select unique option in multiple select box with option group 2010-01-02

    I have a multiple select box with options group like: <select id="sel_salaryrange" name="salaryranges[]" size="8" multiple="1"> <optgroup label="PKR" class="PKR"> <option value="1">15000 - 20000</option> <option value="2"

  • can we get the multiple values from a select tag through Ajax script in controller in MVC? 2010-05-13

    can we get the multiple values from a select tag through Ajax script in controller in MVC? I Have tried for Single Value that I have done by .val Function.. But not for Multiple Values Any suggestion Please Help --------------Solutions-------

  • Problem with multiple select removing more than 1 option 2010-06-12

    Ok, there seems to be a problem with the JS Code for Opera browsers, as it only removes the last option tag that is selected within a multiple select tag, can someone please help me. Here is the HTML for this: <select id="actions_list" name="layou

  • fix the last changed element in multiple select tag? 2010-07-26

    i have a multiple select tag <select multiple="multiple" size="5" id="cities_select"> <option value="1">city1</option> <option value="2">city2</option> <option value="3">city3</option> <option value="4"

  • HTML select tag with multiple selections? possible? 2011-05-31

    I'm looking for HTML list tag where user can select several options from the list, similar to <select> tag with the exception of selecting several options at once What I'm looking for exactly is something very similar to jList in Java, which th

  • Change value of another SELECT tag, when selecting different select options 2011-08-10

    I have a select tag, where users can select what TYPE of exposure they want for their clicks: <select name="exposure"> <?php while($a = mysql_fetch_assoc($r)): ?> <option value=""><?php echo $a['exposure']; ?></value>

  • How do I get a drop down/select option have Multiple Values 2012-01-28

    I've read other questions on here that dealt with what I am looking for. But it still did not help me. I want to have multiple values in an option of the select tag of a form that will be posting the information onto a different file that is viewable

  • struts2 select tag multiple 2009-04-16

    I am using struts2 select tag: this is the code <s:select name="fmrTenant.terminationReason" multiple="true" headerKey="-1" list="rejectionReasons" value="%{fmrTenant.terminationReason}" required="t

  • Adding options to SELECT tag via JS ..Are not styled by CSS? 2009-09-14

    I have a select tag that looks like this: <select style="background:#fa7171; color:#FFFFFF;" name="product_type_sub" id="product_type_sub" onChange="ajaxFunction(1);"> <option value="None Selected">None Selected</option> </select

  • Tabulating an option of a select tag 2009-11-16

    I am currently developing a Struts (1.3.10) application and I'm trying to show in a combo box a set of data. Every single option(row) is a String created by the union of 3 different Strings. My question is if it's possible to tabulate that informatio

Copyright (C), All Rights Reserved.

processed in 0.441 (s). 13 q(s)