Welcome Guest, Not a member yet? Register   Sign In
Textarea field/data does not recognize "New Line"
#1

[eluser]justmelat[/eluser]
I searched thru the forums but didn't see this exact issue. I did see messages regarding textarea fields adding additional lines, but in my case, there is no line return captured at all.

In my CodeIgniter application, the user selects a textArea field as an input field for their app and enter lengthy text that requires the use of the return key. Example they enter two paragraphs of info, and want to see the space between the paragraphs. When the data is submitted to the db from that field and then displayed in the detail section, the application does not capture the pressed of the return key, so all the text is strung together. [See example].

I enterd three lines in my textArea field, hitting the return after the first two lines, but when I display the data, the line returns are not captured.

Does anyone know how I can resolve this?

[linux server, CI verions '1.7.1']
#2

[eluser]DiLer[/eluser]
I found this post by googling for something. Maybe this is a waste of my time, but here is a solution to the problem:

CodeIgniter has a library called 'Typography'.
http://ellislab.com/codeigniter/user-gui...raphy.html

You can use this library to add
Code:
<p>
and
Code:
<br>
to text where it belongs. Alternatively you could just use the normal PHP function nl2br().
#3

[eluser]Aken[/eluser]
Yes, keep in mind that when you echo this data from the database, it will print the new lines (check your source code). HTML doesn't do anything with line breaks, though - you need to tell it to add HTML when there are breaks. DiLer's suggestions should work great for you.




Theme © iAndrew 2016 - Forum software by © MyBB