CalcBuilder Forum

How to use multiple option form field?

User TheFencepedia 2025-11-15 18:42:00

hi there,

I've built a form that uses several multiple option fields, but when I generate the form, that field just shows up as the text "Array."

How do I configure the exit layout to show the options that were selected?

Your explanation in the documentation doesn't really make total sense.

Thanks!

Moonsoft support 2025-11-17 09:49:00

Hi,
yes, the related documentation section means if you have a multiple option field called 'myfield', you will get at your php code, or output section, a 'list/array' of values (or empty if not selected),so you can print the first option recovered using

##myfield##

and the second one with

##myfield##

..etc. Of course you can also use these values at your code section, with $myfield, $myfield....etc


This array/list $myfield contains the 'values' selected you have given to each option, but you have also available the 'texts' of the options with

$myfield_name

array. You can print ##myfield_name##, ##myfield_name## ....etc


Apart from this basic handling, there is a huge set of functions able to work with arrays, some examples:


let's say you want to print all selected 'values' at your output without writing each position:

at the code:

$finaloutput=implode(" ",$myfield); //this means, concatenate all values, separated by blank space


now you can print ##finaloutput## at your output section.


same for the 'texts' selected,

$finaloutputtxt=implode(" ",$myfield_name); //this means, concatenate all texts, separated by blank space

now you can print ##finaloutputtxt## at your output section.


Another useful function is array filter, that you can use to clean this list for the non-selected options that you're getting as 'empty' options:

$cleanArray = array_filter($myfield_name); //Now we have removed the 'non-selected' options
$finaloutputclean=implode(" , ",$cleanArray); //this means, concatenate all values, separated by comma

now you can print ##finaloutputclean## at your output section.


Hope this helps, please let us know if you need more detail about any of the functions.

Thanks, regards
Silvia Martín
Moonsoft Team




...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!