How to get text to wrap into a form input field

Heya,

Does anybody know how to make text wrap inside a form’s text field? It needs to be an input element rather than a text area as I need to pre-populate the field (and currently I only know how to do that with an input element!)

Currently the text is running off out of view horizontally. I have tried messing with the break points but nothing seems to do it.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Hi Laura, you want a textarea.

If you’re pre-populating it with JS, then you’re probably setting the value attribute on your input element. It’s the same for a textarea.

If you use a custom element to create your textarea, you can actually bind the value property directly to a CMS field.

Thanks so much for the reply. I’ve had a fiddle and I’m still head scratching (I should probably add I’m fairly new to webflow!) Below is the script & method i used to attach the cms to the form input field. it works like a charm but doesn’t seem to ‘bind’ when used for a text field? Any other pointers you have would be much appreciated :)

I’m the author of SA5, and I hadn’t actually noticed this before.
The library you’re using sets the attribute of the element and for INPUT elements, that will initialize the current value.

TEXTAREA elements behave a bit differently. If the value is set at page load, it will initialize, but if you set it with script after the page loads ( like here ), it does not recognize it and will not initialize.

That might be a browser bug, at least in Chromium, however it’s a use case that makes sense, so I’ve decided to make a special case here. When you try to initialize the value attribute of a textarea element, it will now initialize the value property as well.

I’ve just released an update, change your library version and you should be good.

<!-- Sygnal Attributes 5 | HTML --> 
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.22/dist/css/webflow-html.css"> 
<script defer src="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.22/dist/nocode/webflow-html.js"></script>

Great to meet you author of SA5! That did it. :grinning:

HUGE thanks. That has been baffling me for days. Hopefully this helps someone with a similar scenario in the future too.

1 Like