Page 1 of 2
Passing Default Values to FormBuilder Text Area
Posted: Thu Oct 05, 2023 1:34 pm
by webform
I have a LISE Instance and i'm trying to pass the LISE text area value to a FormBuilder text area, but it doesn't include the line breaks from LISE.
Is it at all possible to have the line breaks in the FormBuilder text area?
Code: Select all
{FormBuilder form='My Form' value_fld25=$description}
Re: Passing Default Values to FormBuilder Text Area
Posted: Thu Oct 05, 2023 3:02 pm
by WDJames
Is the text area visible to the user? If not, then can you add the line breaks on the form output instead?
Re: Passing Default Values to FormBuilder Text Area
Posted: Thu Oct 05, 2023 3:16 pm
by webform
Yes, the form and the text area is visible for the user, so they can edit the data and update the LISE instance.
So it is important that the text preserves line breaks in the form's text area.
Re: Passing Default Values to FormBuilder Text Area
Posted: Thu Oct 05, 2023 3:45 pm
by Jo Morg
If you are using FormBuilder with the default template, it may be difficult to achieve what you want as it's likely that it will strip it from any non ASCII readable character, and that may include line breaks (I'd have to look at the code to be sure though). Alternatively I'd use a custom template and then just use plain html and set description inside it.
Code: Select all
<textarea name="{$actionid}{$fld25->input_id}">{$description}</textarea>
You'd likely have to use some logic inside the fields rendering loop to render your version of the text area instead of the default one. As I usually use my custom templates with FB it's pretty straight forward for me.
HTH
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 11:15 am
by webform
Thanks for the suggestion. I have now tried that but it gave the same result.
I also tried to test by hardcoding a form with a textarea and here too the newline was ignored.
The question is how can the LISE module show line breaks in admin for a non-wysiwyg textarea, but I can't do it in the frontend?
Code: Select all
<form>
<textarea name="description" id="description" cols="40" rows="5">{$foo}</textarea>
</form>
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 11:20 am
by Jo Morg
Honestly I have been working with LISE/FB combo for a long time, even managed to create a CRM system around them some time ago, and never had that issue. I suspect something else may be at play there. Difficult to pinpoint without more info... at this point I don't even know how you get {$foo}
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 11:44 am
by webform
I have a LISE Detail Template where i test output:
Code: Select all
{$foo = $item->fielddefs.description.value}
<form>
<textarea name="description" id="description" cols="40" rows="5">{$foo}</textarea>
</form>
My first intial LISE Detail Template was:
Code: Select all
{$title = $item->title}
{$author = $item->fielddefs.author.value}
{$project = $item->fielddefs.project.value}
{$description = $item->fielddefs.description.value}
{FormBuilder form='edit_lesson' value_fld21=$title value_fld22=$author value_fld23=$project value_fld25=$description}
I've also tried to use nl2br but it just output the br tag as plain text in the textarea.
Also my Field Definition in both LISE and FB is a non-wysiwyg textarea.
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 11:52 am
by Jo Morg
OK then, try this:
Code: Select all
{$title = $item->title}
{$author = $item->author}
{$project = $item->project}
{$description = $item->description}
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 12:52 pm
by webform
Thanks for the suggestion. Alas output is the same result with all text in one line.
I've also tried to change my textarea in LISE and FormBuilder to wysiwyg, but then the textarea displays p and br tags as plain text and ignoring the multiline content.
I'm trying to do a frontend edit form for my LISE Instance, but have no luck so far. A frontend submit new to LISE works like a charm.
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 1:02 pm
by Jo Morg
As I said: I do it all the time, so I'm not sure what is going on there.
Having said that, a frontend editor for LISE is almost ready for release. Can't give you a time frame yet but it is already in beta testing so shouldn't take much longer. Stay tuned!
Re: Passing Default Values to FormBuilder Text Area
Posted: Fri Oct 06, 2023 1:51 pm
by DIGI3
In JoMorg's method you may need to add |nl2br (newline to <br>) on the variable, so
<textarea name="description" id="description" cols="40" rows="5">{$foo|nl2br}</textarea>
Re: Passing Default Values to FormBuilder Text Area
Posted: Sat Oct 07, 2023 2:08 pm
by webform
Thanks to JoMorg's information, i've done some additional testing and discovered it works on the CMSMS Default Theme but not on the Theme i'm implemented on my working site.
Can't figure out what is removing the line breaks in my theme as i can't see anything out of the ordinary in the inspect css code.
I've even disabled all JS for the page to be sure it's not anything in there removing the line breaks.
Working: https://lab.webform.dk/isc/index.php?page=form-test
Not working: https://lab.webform.dk/canvas/index.php?page=form-test
Re: Passing Default Values to FormBuilder Text Area
Posted: Sat Oct 07, 2023 2:21 pm
by Jo Morg
Sometimes we add (I've been bitten by it too) one too many {strip}....{/strip} or {'...'|strip} to the templates. I'm not sure but it could be the cause for something like this. So look for those and comment them out or temporarily remove them to test it.
Re: Passing Default Values to FormBuilder Text Area
Posted: Sat Oct 07, 2023 2:47 pm
by webform
You are a lifesaver!!!
It was precisely a strip tag that caused the trouble. It hadn't even crossed my mind to look at strip tags.
Thank you so much for pointing me in the right direction and saving the day.

Re: Passing Default Values to FormBuilder Text Area
Posted: Sat Oct 07, 2023 2:49 pm
by Jo Morg
You're welcome
