I want to generate a select list that should look like the following-
<select name="isActive">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
For this I am using select()
HTML helper in ColdBox.
#html.select(
options=qActiveOptions,
nameColumn="value",
name="isActive",
label="Active:",
required="required",
title="Active",
)#
Where qActiveOption is the query that I created using the code below-
<cfset qActiveOptions=queryNew('name,value', "VarChar,VarChar")>
<cfset queryAddRow(qActiveOptions,2)>
<cfset querySetCell(qActiveOptions,'name','yes',1)>
<cfset querySetCell(qActiveOptions,'value','True',1)>
<cfset querySetCell(qActiveOptions,'name','no',2)>
<cfset querySetCell(qActiveOptions,'value','False',2)>
This generates the desired result but as you can see I have to create a new query object just for that. I read the documentation of the select
HTML helper and found that we can also provide array of objects to populate it.
Is there any other option to populate a select list such as by providing a structure with name and value pair.