Welcome Guest, Not a member yet? Register   Sign In
textarea not allowing linebreaks
#1

[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 :(';
  }
  
}


Messages In This Thread
textarea not allowing linebreaks - by El Forum - 01-07-2013, 10:53 PM
textarea not allowing linebreaks - by El Forum - 01-09-2013, 09:45 AM
textarea not allowing linebreaks - by El Forum - 01-09-2013, 09:50 AM
textarea not allowing linebreaks - by El Forum - 01-09-2013, 11:10 AM
textarea not allowing linebreaks - by El Forum - 01-10-2013, 04:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB