views:

25

answers:

1

Hi all,

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.

A: 

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

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.

Leo