Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Adding line breaks to text fields
Adding line breaks to text fields [message #4088] Tue, 04 March 2014 06:42 Go to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
I found a workaround within the framework. There are two steps to this:

Step 1:
Add the line of code
$cellspec['text'] = str_replace ( "<br>", chr(10),  $cellspec['text'] );


in the function
detailView_multi (&$dbobject, $zone, $current_row)
just below the line
$cellspec['text'] = str_replace('&nbsp;', $nbsp, $cellspec['text']);
in the file std.pdf.class.inc

Step 2:
In the cell where one wants to introduce the line break you can introduce the string "<br>" such that for example if you want to print "hello world" but with a line break then you would have to modify the text string to "hello<br>world".
Re: Adding line breaks to text fields [message #4090 is a reply to message #4088] Wed, 05 March 2014 04:40 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
This is not necessary. If you want to put a line break in a text string then use '\n' as this is the PHP standard.

Re: Adding line breaks to text fields [message #4091 is a reply to message #4090] Wed, 05 March 2014 05:52 Go to previous messageGo to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
The '\n' character did not introduce the line break as I had expected in the version 1.79.0 of Radicore that I am using in the Detail PDF report from within the _cm_output_multi ($name, $fieldarray) function. However, there is a possibility that I have introduced the bug myself and so I will test on a fresh installation.

There is another error I am facing in the same report which is that the TCPDF flag K_CELL_HEIGHT_RATIO is not effective.

While it works in the header, it does not work on data published using the _cm_output_multi ($name, $fieldarray) function.
Re: Adding line breaks to text fields [message #4092 is a reply to message #4091] Wed, 05 March 2014 06:06 Go to previous messageGo to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
I tried on a fresh installation and the first bug persists.

[Updated on: Wed, 05 March 2014 06:20]

Report message to a moderator

Re: Adding line breaks to text fields [message #4093 is a reply to message #4092] Wed, 05 March 2014 06:19 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
If you logon to the demonstration system on the Radicore website at http://www.radicore.org/demo/menu/logon.php and go to page
Home»PROTO»Example System»List Person, then select a person and press the 'Output to PFD (D)' button you will see a PDF report which shows the address details in a single text box which spans multiple lines because it contains line breaks. In you look inside file x_person.class.inc for the _cm_output_multi() method you will see that the code constructs an address string with "\n" after each line.



Re: Adding line breaks to text fields [message #4094 is a reply to message #4093] Wed, 05 March 2014 06:22 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
I do not understand your problem with K_CELL_HEIGHT_RATIO as I never touch it with my PDF class.

Re: Adding line breaks to text fields [message #4095 is a reply to message #4093] Wed, 05 March 2014 06:22 Go to previous messageGo to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
You are right the '\n' character works in the example application.

[Updated on: Wed, 05 March 2014 06:23]

Report message to a moderator

Re: Adding line breaks to text fields [message #4096 is a reply to message #4095] Wed, 05 March 2014 06:37 Go to previous messageGo to next message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
This must be my mis-understanding of how php works but it is interesting to share with you what I found.

Apparently, the following code does introduce the new line character:
$str1 = "faraz";
$str2 = "haider";
$str3 = $str1."\n".$str2;

while the code that follows next does not:
$str1 = "faraz";
$str2 = "haider";
$str3 = $str1.'\n'.$str2;

[Updated on: Wed, 05 March 2014 06:45]

Report message to a moderator

Re: Adding line breaks to text fields [message #4097 is a reply to message #4096] Wed, 05 March 2014 10:00 Go to previous message
AJM is currently offline  AJM
Messages: 2370
Registered: April 2006
Location: Surrey, UK
Senior Member
That is correct. When "\n" is enclosed in double quotes the "\" (backslash) character is treated as an "escape" character which then converts the "n" into a newline. When enclosed in single quotes the '\' character is treated as a plain backslash and not an escape character.

Previous Topic: Change number of columns in PDF list report
Next Topic: PostgreSQL error
Goto Forum:
  


Current Time: Tue Nov 26 17:13:16 EST 2024

Total time taken to generate the page: 0.01175 seconds