Passing Default Values to FormBuilder Text Area Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Passing Default Values to FormBuilder Text Area

Post 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}
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: Passing Default Values to FormBuilder Text Area

Post by WDJames »

Is the text area visible to the user? If not, then can you add the line breaks on the form output instead?
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post 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
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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>
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post 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}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post by Jo Morg »

OK then, try this:

Code: Select all

{$title = $item->title}
{$author = $item->author}
{$project = $item->project}
{$description = $item->description}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post 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!
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1630
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Passing Default Values to FormBuilder Text Area

Post 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>
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post 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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
webform
Power Poster
Power Poster
Posts: 461
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: Passing Default Values to FormBuilder Text Area

Post 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. ;D
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1924
Joined: Mon Jan 29, 2007 4:47 pm

Re: Passing Default Values to FormBuilder Text Area

Post by Jo Morg »

You're welcome :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “Modules/Add-Ons”