text area default text line breaks

jimmyt 20 Aug, 2013
Hi,

I want to display a few paragraphs in a text area. When I copy the paragraphs in the default value field, it seems all the line breaks get removed. Is there a way to preserve them?

Thanks
jimmyt 20 Aug, 2013
I find the only way to have some carriage returns in text areas is to copy & paste the text with carriage returns directly in the database (_chronoforms -> content). This still allows the editing of the form with the wizard, but every time the form is saved with the wizard the modifications have to be made in the database.

incidentally, setting the text area as readonly also works that way (see http://www.chronoengine.com/forums.html?cont=posts&f=26&t=24194&hilit=readonly).
GreyHead 21 Aug, 2013
Hi jtalbot,

I'm not quite sure what the problem is? Have you tried turning off the Rich Text editor and using <p> or <div> or <br /> tags?

Bob
jimmyt 21 Aug, 2013
Thank you for the reply.

I mean carriage returns inside a text area - plain ascii text...
GreyHead 21 Aug, 2013
Hi jtalbot,

Have you tried using <p> or <div> or <br /> tags?

Bob
jimmyt 21 Aug, 2013
Yes; as expected, the HTML tags show up in their raw form in the text area on the front-end view of the form.
jimmyt 31 Aug, 2013
This continues to be an issue. I get the impression that you are not sure what I am talking about. In the image below, I believe the highlighted text box should be a multi-line text box, to allow the preservation of carriage returns. There also seems to be some other filtering going on elsewhere; when submitting an email that includes the text area, the carriage returns are also filtered out. This used to work fine in the previous version of ChronoForms.

text area default text line breaks image 1
GreyHead 01 Sep, 2013
Hi JTalbot,

Sorry I did miss the point before.

If you need a multi-line default value then I think that you can set it up using a Custom Code action in the Form On Load event like this:
<?php
if ( !isset($form->data['text_privacy_policy']) ||  !$form->data['text_privacy_policy'] ) {
  $form->data['text_privacy_policy'] = "<p>Sed in pulvinar felis, . . .</p><p>. . . interdum cras amet.</p>";
}
?>

I think that will work OK.

For the linebreaks you can use this in a Custom Code action in the On Submit event to convert line-breaks to <br /> tags
<?php
$form->data['this_textarea'] = nl2br($form->data['this_textarea']);
?>

Bob
tcrwstiepel 26 Nov, 2013
1 Likes

....
For the linebreaks you can use this in a Custom Code action in the On Submit event to convert line-breaks to <br /> tags

<?php
$form->data['this_textarea'] = nl2br($form->data['this_textarea']);
?>

Bob



Dear Bob,

long time I have surched for such a code to have linebreaks in the sended mails - thanks a lot! It works well.

But how can I separate the linebreaks for the DB Save? For the export to Excel it places every new line in a new cell.

kind regards,
kareh
tcrwstiepel 27 Nov, 2013
perhaps this scan is helpfully - so you see what I mean
This topic is locked and no more replies can be posted.