![]() |
Input hidden - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Input hidden (/showthread.php?tid=48872) |
Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] I have a input hidden field and I want to grab the value in my model but this doesn't seem to work Code: 'CustomerID' => $this->input->post('CustomerID'), So i tried this Code: 'CustomerID' => $this->input->hidden('CustomerID'), And then got this error: Quote:Fatal error: Call to undefined method CI_Input::hidden() What should i do to achieve this? Input hidden - El Forum - 01-31-2012 [eluser]ibnclaudius[/eluser] This is the correct: Code: $this->input->post('CustomerID') The problem is probably in your input field, post it. Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] I have this hidden field Code: <?php echo form_hidden('CustomerID', $meeting->CustomerID); ?> Which output a number lets say 3815 so i need to get that value of 3815 and post it to my model in order to post it to the database Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] Also the Code: $this->input->post('CustomerID') Doesn't input into the database, its just inserts a 0 (zero) Input hidden - El Forum - 01-31-2012 [eluser]meigwilym[/eluser] Check that the hidden field is inside the form elements. Next, you can check what $_POST data is sent, by using Code: var_dump($_POST); Your hidden field should be somewhere inside it. If it is, then try Code: var_dump($_POST['CustomerID'); Let us know where you get. Mei Input hidden - El Forum - 01-31-2012 [eluser]ibnclaudius[/eluser] Hmm... It's ok... Have you checked the source code to see if is really outputting a value? Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] Yes checked source its outputtin a number which is what i need but then need to get that number to post to model to post to db Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] [quote author="meigwilym" date="1328046405"]Check that the hidden field is inside the form elements. Next, you can check what $_POST data is sent, by using Code: var_dump($_POST); Your hidden field should be somewhere inside it. If it is, then try Code: var_dump($_POST['CustomerID'); I did the above and this is what i got when i viewed source. array(0) { } <div> <h4>A PHP Error was encountered</h4> <p>Severity: Notice</p> <p>Message: Undefined index: CustomerID</p> <p>Filename: views/editclient.php</p> <p>Line Number: 73</p> </div>NULL bool(false) Input hidden - El Forum - 01-31-2012 [eluser]ibnclaudius[/eluser] Now, try what meigwilym said. Code: var_dump($_POST['CustomerID'); Input hidden - El Forum - 01-31-2012 [eluser]the_unforgiven[/eluser] I have tried what you just posted and get this: <h4>A PHP Error was encountered</h4> <p>Severity: Notice</p> <p>Message: Undefined index: CustomerID</p> <p>Filename: views/editclient.php</p> <p>Line Number: 73</p> NULL bool(false) |