Doctrine: textarea line breaks & nl2br
I'm pulling my hair out with something that should be very simple: getting line breaks to show up properly in text that's returned from the database with Doctrine 1.2
I'm saving a message:
$body = [text from a form textarea];
$m = new Message();
$m->setSubject($subject);
$m->setBody($body);
$m->save();
Querying the message:
$q = Doctrine_Query::create()
->from('Message m')
->where('m.message_id = ?', $id)开发者_开发技巧
->limit(1);
$this->message = $q->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
In my template:
echo $message[0]['body'] ... outputs the text without line breaks
echo nl2br($message[0]['body']) ... no difference
... and I've tried every combination I could think of.
Is Doctrine doing something to line breaks that's affecting this, or is there something that I'm just missing?
Any help would be appreciated.
Thanks.
Solved.
The form sends the data via Ajax rather than submit. Using ajax "get" turns the textarea data into single line. Changing this to ajax "post" fixes the problem.
精彩评论