White space not respected in Details view

anders

New member
Hi there,

the format of a text that is inserted/edited with various (i. e. , more that one) white space characters between the words changes in the Details view. All the white space characters between different words except one are stripped out. However, in the Mysql database the white space characters are preserved correctly.

How to make the Details view reflect exactly how the text was entered?

Anders
 

DebbieS

DaDaBIK Guru
You can go to function get_field_correct_displaying and set those fields to display as preformatted text (put <pre></pre> around the field value part).

This is standard HTML behaviour - multiple spaces are displayed as one via HTML.
 

anders

New member
Hi Debbie,

thanks for your answer. Following your advise I´ve managed to get the Details view to respect the multiple white space between words. However, now an empty line is inserted between each line in the text. How can this be avoided?

Best regards,

Anders
 

DebbieS

DaDaBIK Guru
Post a sample of the exact code from one of these fields. Unless I know what it is being saved as, I don't know how to help.
Thanks!
 

anders

New member
An example of what I am trying to enter is as follows (please note that the underscores "symbolizes" the white space, since multiple white space between words will disappear also in this message!)

aaa_____bbbbbb_________ccccc______dddd
eeeee_____ffff__________ggggg______hhh
iii_______jjjj_____________________kkkkkkk

Without adding the pre tags this is displayed in the Details view as follows:

aaa bbbbbb ccccc dddd
eeeee ffff ggggg hhh
iii jjjj kkkkkkk

With pre tags added it looks like this:

aaa_____bbbbbb_________ccccc______dddd

eeeee_____ffff__________ggggg______hhh

iii_______jjjj___________________kkkkkkk


I. e the pre tags solve the problem with the white space between the words but it adds an additional new, empty line between the lines. Please note that the text always appears correctly in the Edit view!

What I have changed in business_logic.php is line 2818 to the following:

$displayed_part = "<pre>".$field_value."</pre>";

Also, the field in question is defined as a textarea and the content type as alphanumeric.

Best regards,

Anders
 

DebbieS

DaDaBIK Guru
Try this:

[pre]
$displayed_part = "<pre>".preg_replace("/[\r\n]{2,}/i", "<br />", $field_value)."</pre>";
[/pre]

It looks as though the entry is getting a \r\n or combination of, so you need to replace those for display. The regex above should replace any combination occuring 2 or more times in the text.
 
Top