Preserving 'carriage returns'

A place for users and developers of the Xataface to discuss and receive support.

Preserving 'carriage returns'

Postby PaulR » Wed May 25, 2011 4:49 am

I have a text area for users to enter notes so I'd like to preserve CR/LF's (or paragraphs) in the database. The field in the underlying table is of type varchar, size 2048. Searching on the Internet it seems that anything over 255 characters in such a field means it automatically gets converted to a text field.

Short of allowing html (which I'd really prefer not to do), is there any way to achieve the preservation of new lines? I'm not sure whether this is a mysql or Xataface 'feature' so sorry if the question doesn't really belong here!

TIA

Paul
PaulR
 
Posts: 19
Joined: Tue May 17, 2011 10:38 pm

Re: Preserving 'carriage returns'

Postby shannah » Wed May 25, 2011 9:50 am

Carriage returns do get preserved. The issue is likely with your output context (i.e. what you are doing with the data to display). E.g. if you simply display text with carriage returns in HTML it will ignore the carriage returns.

If you are using Xataface's API for displaying the field data for textarea fields, the $record->htmlValue() method will convert carriage returns to <br> tags so that they will show up in HTML - whereas the $record->display() or $record->strval() or $record->val() methods will just leave it unchanged.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Preserving 'carriage returns'

Postby PaulR » Wed May 25, 2011 10:31 am

Sorry Steve, that's a little beyond me. I just want text to appear exactly as entered in a text area in details view. It sounds as if $record->htmlValue() would do the job but I have no idea how to use the API (or whether I should tinker with things I don't understand!). I'll read some more....

Many thanks

Paul
PaulR
 
Posts: 19
Joined: Tue May 17, 2011 10:38 pm

Re: Preserving 'carriage returns'

Postby shannah » Wed May 25, 2011 10:39 am

What mechanism are you using to display the data now?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Preserving 'carriage returns'

Postby PaulR » Wed May 25, 2011 11:37 am

Just the 'built-in' details form via a web browser... is that what you mean?
PaulR
 
Posts: 19
Joined: Tue May 17, 2011 10:38 pm

Re: Preserving 'carriage returns'

Postby shannah » Wed May 25, 2011 11:39 am

That already uses htmlValue().. It should preserve carriage returns.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 20 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved