Post

2 followers Follow
0
Avatar

Retaining line breaks when adding task description via PHP API?

I am using a textarea form field and sending it via GET to a PHP file that adds a task via the API.

I cannot figure out how to get the line breaks in my textarea field to be retained when adding the contents as a description on the task created.

E.g.

"this
is

lines"

becomes

"thisis lines" (or similar)

 

Joshua Hay

Official comment

Avatar

Ah yes, that makes sense. Submitting via GET would do that. Why don't you just use POST?

Casper Fabricius

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Joshua,

Using regular escaped linebreaks should work just fine. I.e. send "this\nis\nlines" to the API.

Casper Fabricius 0 votes
0
Avatar

I know this is probably a weird workaround but what I ended up doing to get it working was to use a javascript function to convert all \n type characters to HTML <br/> tags before sending the textarea contents through as GET variables via AJAX to my PHP script. Then the PHP script replaces all <br/> tags with \n again before submitting to the Podio API. Otherwise, I found that the line breaks were removed completely when submitting textarea.val() via AJAX as GET variables.

Joshua Hay 0 votes