• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass data from a view to a controller?

#11
[eluser]laytone[/eluser]
try this

Quote:My controller has the following code:
$project_id = $this->input->post(“ProjectID”);
echo $project_id;

Code:
echo "<pre>";
print_r($_POST);
echo "</pre>";

This way you can see all the variables that your form is posting. Maybe in your html the hidden fields are not within your &lt;form&gt;&lt;/form> tags?.?.?

#12
[eluser]theciman[/eluser]
Thanks but I tried that with no results. I do believe I have all the form tags correct:

&lt;form&gt;
&lt;/form&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt; TRMC T&E S&T &lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>Database Update</h1>
Project Details:<br />
<pre>
&lt;form action="http://abc.ef.com/ll/index.php/updateprojects/update_project" method="post"&gt;
......
......
&lt;/form&gt;
</pre>
&lt;/body&gt;
&lt;/html&gt;

The funny thing is when I make the form viewable it works fine.

#13
[eluser]laytone[/eluser]
Can you post the rendered html view and also the function you are posting to without removing any of the actual code?

Quote:The funny thing is when I make the form viewable it works fine.

what do you mean by this and how is it that you are hiding it?

#14
[eluser]theciman[/eluser]
What I meant is I am using a form_hidden which gives me this problem. Once I change the form_hidden to say form_input then everything works fine. This is why I think there is something wrong with the form_hidden function. I am questioning whether one can pass a value to a controller using $this->input->post coming from a form_hidden function. I am told I should be able to pass a value but it does not seem to work. The value is correct in the html code I show above but yet the post shows nothing. Once I make the form visible like a form_input than the value is captured by the post method and I can view it, modify it, and use it to insert values into my database.

#15
[eluser]laytone[/eluser]
I do it every day. Will you post the html code of your form rendered. from the <from XXX > to the &lt;/form&gt; without taking anything out. (the version with hidden fields) I'm sure we will be able to figure out whats wrong very quickly.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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