In what form and shape should data be in data-smtfm-selected to populate multiple values in a Multi-select field in a SmartForms form?
I've tried both an array and comma separated string but no values is selected. If i only send a single string value to data-smtfm-selected then it works.
<label for="project_compare">Projects</label>
<select multiple class="form-select required" id="project_compare" name="project_compare[]" data-smtfm-selected="{$form_data->project_compare}">
<option value="25051">25051 - Test Project</option>
<option value="25052">25052 - Test Project</option>
<option value="25053">25053 - Test Project</option>
<option value="25054">25054 - Test Project</option>
<option value="25055">25055 - Test Project</option>
</select>
SmartForms preload Multi-Select Values
Re: SmartForms preload Multi-Select Values
I'm not sure if it's a bug that it doesn't work, or just a feature that was never added, but I do something like this:
Code: Select all
<option value="25051"{if in_array('25051', $form_data->project_compare|default:[])} selected{/if}>25051 - Test Project</option>
Not getting the answer you need? CMSMS support options