[eluser]Volkof[/eluser]
Hilo guys,
This is quite strange but for my textarea when user type something, press enter key (newline) and submit, it does not display the "linebreak". To put it simply, my textarea does not seem to support line break.
I have a feeling because when the text are sent to database and retrieved, the linebreak (<br>) isn't saved at all. I also find it curious how forum textarea such as this one is able to maintain the linebreaks.
Here is my view:
Code:
//Create a textarea for Comments
$commentForm = array('id' => 'commentForm');
echo form_open('comment/addComment/', $commentForm);
$comment = array(
'name' => 'comment',
'rows' => '4',
'cols' => '30',
'id' => 'commentbox',
'onkeypress' => 'submitComment()',
);
echo "<p>Your comment for this review:<br/>";
echo form_textarea($comment);
echo "</p>";
echo "<p>";
echo form_submit('submit', 'Post Comment');
echo "</p>";
echo form_hidden('reviewID', $row->reviewID);
echo form_close();
Here is the Controller:
Code:
public function addComment()
{
$comment = trim($this->input->post('comment'));
$reviewID = $this->input->post('reviewID');
if($comment != ''){
//Get UserID from Session
$userID = $this->members();
echo '<br/>Commenter = '.$userID;
$this->comment_model->addComment($comment, $userID, $reviewID);
echo 'Comment added!';
}else{
echo 'You didnt comment anything :(';
}
}