Submit request to CFWheels selectTag form helper or comma list in string elements

I have a query that returns names in a format <lastnamd>, <firstname>

like

<cfquery name="instructorSelectList" dataSource="GIRSReport">
    SELECT instructor_DBID,
           last_name + ', ' + first_name as instructor_name,
           hid
    FROM   instructors
    WHERE working_status = 'active'
    ORDER BY last_name, first_name  
</cfquery>

      

I want to use this query for the selectTag helper. If I do this:

    #selectTag
    (
        name="inst",
        id="program",
        options="#ValueList(instructorSelectList.instructor_name)#",
        valueField="#ValueLIst(instructorSelectList.instructor_DBID)#",
        display="#ValueList(instructorSelectList.instructor_name)#",
        selected="",
        label="HID",
        multiple="no",
        includeBlank="true",
        size=1,
        class="form-control",
        prepend="<br/>"
    )#

      

Then I get a list like <lastname1>, <firstname1>, <lastname2>, <firstname2>, ...

which is clearly not what I want.

If I just try to pass a parameter options

to the request, for example options="#instructorSelectList.instructor_name#"

, the parameters won't populate as expected.

The idea is to use a form helper equivalent to

<cfselect
    name="inst" 
    query="instructorSelectList" 
    queryPosition="below"
    value="instructor_DBID" 
    display="instructor_name" 
    label="HID" size=1
    class="form-control">
    <option value=""></option>
</cfselect>

      

+3


source to share


1 answer


I think you need to pass the query name in Options, without quotes (or in quotes surrounded by hashes) while the column names are specified.

#selectTag
(
    name="inst",
    id="program",
    options=instructorSelectList,
    valueField="instructor_DBID",
    textField="instructor_name",
    selected="",
    label="HID",
    multiple="no",
    includeBlank="true",
    size=1,
    class="form-control",
    prepend="<br/>"
)#

      



More information: CFWheels selectTag () documentation

+3


source







All Articles