[coldbox 3.8.1] html.select with multiple select

I’m attempting to use html.select as a multiple select, but can’t seem to work out how I would put it together, or even if it can be done.

I have the following:
`

#html.select(multiple=“true”, name=“employmentStatus”, bind=rc.profile.getEmploymentStatus(), bindProperty=“id”, options=Application.lookups.list(‘profile’,‘employment_status’), column=“id”, nameColumn=“description”, class=“form-control”, wrapper=“div class=‘col-md-8’”)#

`

Application.lookups.list(‘profile’,‘employment_status’) populates the options.

rc.profile.getEmploymentStatus() holds an array of objects for the currently selected options.

the id property of rc.profile.getEmploymentStatus() holds the value of the currently selected items. There can be more than one (thus an array of objects).

From what I can tell, the way I have set the method up, and the properties passing in, should tie it all together, but it doesn’t. Currently the select is populated with 4 options, and 2 should be selected, but the aren’t. The id property in both of the objects in the rc.profile.getEmploymentStatus() array should match the id column of 2 of the options, but they don’t.

Can anyone see if I am totally missing something here?

Many THanks!

Jason

By looking at the code, ColdBox HTMLHelper. The multiple atrribute is always set to true later and doesn’t use the argument for anything. The other thing I noticed is that it will only be true if the relationship is Many to Many.

Thanks Andrew. I’m not really sure I follow what you mean about the mulitple attribute. Are you saying that this wouldn’t effect the entity I am trying to bind to?

Yes, rc.profile.getEmploymentStatus() is a many-to-many relationship. The id attribute I am trying to bend to with bindProperty is the id of the target table.

From looking at the HTMLHelper yes, for example here is that snippet of code. You will notice it is not used.

var buffer = createObject("java","java.lang.StringBuffer").init('');

// ID Normalization
normalizeID(arguments);
// group wrapper?
wrapTag(buffer,arguments.groupWrapper);
// label?
if( len(arguments.label) ){ buffer.append( this.label(field=arguments.id,content=arguments.label,wrapper=arguments.labelWrapper,class=arguments.labelClass) ); }

//wrapper?
wrapTag(buffer,arguments.wrapper);

// disabled fix
if( arguments.disabled ){ arguments.disabled = “disabled”; }
else{ arguments.disabled = “”; }
// multiple fix
if( arguments.multiple ){ arguments.multiple = “multiple”; }
else{ arguments.multiple = “”; }

// create select
buffer.append("<select");
flattenAttributes(arguments,“options,column,nameColumn,selectedIndex,selectedValue,bind,bindProperty,label,wrapper,labelWrapper,groupWrapper,labelClass”,buffer).append(">");

// binding of option
bindValue(arguments);
if( structKeyExists(arguments,“value”) AND len(arguments.value) ){
arguments.selectedValue = arguments.value;
}

// options, are they inflatted already or do we inflate
if( isSimpleValue(arguments.options) AND findnocase("",arguments.options) ){
buffer.append( arguments.options );
}
else{
buffer.append( this.options(arguments.options,arguments.column,arguments.nameColumn,arguments.selectedIndex,arguments.selectedValue) );
}

// finalize select
buffer.append("");

//wrapper?
wrapTag(buffer,arguments.wrapper,1);
// group wrapper?
wrapTag(buffer,arguments.groupWrapper, 1);

return buffer.toString();