Gossamer Forum
Home : Products : DBMan : Installation :

Allowing carriage returns in text area

Quote Reply
Allowing carriage returns in text area
How do I allow carriage returns in the text area? Currently, they are being stripped.

In a previous post, Georg said:
Quote:
$rec{'Comments'} =~ s/\n/<br>/g;
(replacing 'Comments' with the field you want to have printed out properly).
Put this somewhere at the beginning of
sub html_record.

I think this was designed for an older version of DBMan. I have the newest version.
Quote Reply
Re: Allowing carriage returns in text area In reply to
Awesome, that works Smile

Although, right after a user posts new data, it kills the carriage returns, but when you "list all" or "search", it shows the carriage returns properly. So there must be one other area to do this to. Any ideas ?



[This message has been edited by Katana Man (edited January 07, 1999).]
Quote Reply
Re: Allowing carriage returns in text area In reply to
Yeah but there is no sub html_record in the newest version.

The closest match is
sub build_html_record or sub build_html_record_form

Where do I put this code? The field that I want to have this for, is "Description", so where do I put:
$rec{'Description'} =~ s/\n/<br>/g;

I have placed this code at the beginning of both of these places, but it does not work.

[This message has been edited by Katana Man (edited January 07, 1999).]
Quote Reply
Re: Allowing carriage returns in text area In reply to
Have you looked in the html.pl file? That's where the html_record and html_record_form subroutines are. That's where you can design your own form and record display.

Are you using the autogenerate feature of DBMan? If so (and you want to stay with that), it'll be a little more work to keep your linefeeds.

In html.pl, sub view success, change

for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}

to

for (0 .. $numhits - 1) {
print "<P>";
%rec = &array_to_hash($_,@hits);
$rec{'Description'} =~ s/\n/<br>/g;
&html_record (%rec);
}

This should work, although I haven't tested it.


------------------
JPD
Quote Reply
Re: Allowing carriage returns in text area In reply to
Nope. That's for every version of DBMan.

The command $rec{'Comments'} =~ s/\n/<br>/g;

in "perl-ease" means

"In the field 'Comments' take every carriage return (\n) and replace it with a <BR> (html line break)."


------------------
JPD
Quote Reply
Re: Allowing carriage returns in text area In reply to
You'll need to add similar things to html_add_success and html_modify_success in order for it to print out.

change

&html_record(&get_record($in{$db_key}));

to

%rec = &get_record($in{$db_key});
$rec{'Description'} =~ s/\n/<br>/g;
&html_record (%rec);


in both of those subroutines. Basically, you want to get the info (&get_record), convert the field (s/\n/<br>/g) and then send everything to html_record.





------------------
JPD


[This message has been edited by JPDeni (edited January 07, 1999).]
Quote Reply
Re: Allowing carriage returns in text area In reply to
Ah yes! Even better. Everything now works correct except when you click modify, and then list all.

Thank you so much for all that you have done so far JPDeni !! I appreciate it.
Quote Reply
Re: Allowing carriage returns in text area In reply to
And just to point out, the script is not stripping the carriage returns. If you do a view source, you'll see that they are there! However, web browsers don't care about carriage returns, they much prefer <br> tags if you want to display new lines.

Cheers,

Alex
Quote Reply
Re: Allowing carriage returns in text area In reply to
Well, you could also add right after:

my (%rec) = @_;
$rec{'Description'} =~ s/\n/<br>/g;

in html_record. Should have to change anything else..

Alex
Quote Reply
Re: Allowing carriage returns in text area In reply to
You'll also need to add the lines to html_modify_form and html_delete_form.

Basically, you need to add it to all the subroutines that have a call to

&html_record

I think I've named them all, but I may have forgotten one or two.

You're welcome. Smile


------------------
JPD