• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass ID through a form?

Hi guys,

In my view, I have a review(basically a paragraph of text) and a comment box at the bottom. Since the review is fetched from database, I have the reviewID.
So now what Im trying to do is when a user enters comments into the box and click submit, the reviewID and comments will be passed to the controller to store into the database.
Problem is I'm not sure how to pass the reviewID through <form>

echo form_open('comment/addComment/');
  //echo validation_errors();
  $comment = array(
              'name'        => 'comment',
   'rows'  => '4',
              'cols'        => '30',
  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_close();

I tried
echo form_open('comment/addComment/'$row->reviewID);
but it does not work.

Any idea? Thanks in advance


I would use a hidden form field for this. Before your "form_close();" add:

echo form_hidden('reviewID', $row->reviewID);

Then, in your controller, you can access the value with


Check out the form helper for more information about creating hidden fields:

Thanks Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.