Handling Multi-line text in blox
Noticed an odd behavior with multi-line text inputs in blox.
If I define a text input as multiline...
{
"type": "Input.Text",
"id": "data.Parameters.NOTES",
"defaultValue": "",
"isMultiline": true,
"rows": "5",
"value": "{panel:NOTES}"
},
I can enter text with new lines as expected
We save this to a database by an API, then retrieve it. If we just display the data, newlines are preserved (bottom of the picture below) BUT the same panel value in the text input is rendered with the <br/> tag embedded in it (top of the picture below)
{
"type": "TextBlock",
"id": "",
"class": "",
"spacing": "small",
"weight": "normal",
"widget": "90%",
"text": "{panel:NOTES}"
},
Embedding the <BR/> tag makes sense when the value is being shown as a Text Block, but not when it is placed into a Text Input.
Is there a blox setting that will allow the Text Input to render as expected, or do I need to hack around it with javascript in the widget?
bbontrager
Posted 2 years ago·Last reply 2 years ago
2 comments
DRay
·2 years agoHello bbontrager ,
I wanted to follow up to see if the solution offered by ILLIA worked for you.
If so, please click the 'Accept as Solution' button so other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.
Thank you.
Ilya Kvashenko
Admin2 years agoHello bbontrager
This behaviour is happening because text block can render HTML elements (it is separated as HTML block in components but it is still the same block)
As a solution, you might want to replace <br/> with \n, this way text area will be able to read new line and show data as expected.
Please inform if you have any questions.
Best regards,