Dropdown classic multiline option list from a PHP variable - how to add line breaks

Display a dropdown list with multiple options from a PHP variable.

Overview

The issue occurs when using newline characters in a string variable, which does not create separate options in the dropdown.
Return the PHP variable as an array directly, without converting it to a string, to ensure each item appears as a distinct option.

Answered
ChronoForms v7
ri rikulahteenmaki 18 Feb, 2024
I am generating a dropdown options list from a PHP variable. Adding "\r\n" to end of each line in the variable data does not make new lines, when the dropdown is rendered in the form. I only get one long string as a selection option, instead of a list of multiple selection options.
How can I get the new lines show in the selection list?
I have Linux and Firefox browser.
ri rikulahteenmaki 19 Feb, 2024
Answer
1 Likes
SOLVED: the drop select options show correctly, when the PHP variable is returned as an array. You do not need to explode the array into a string at all, thus avoiding the new line character issue.
This topic is locked and no more replies can be posted.