validation questions |
[eluser]jorre[/eluser]
I'm looking for a solution for the following (CI-newb) situation: I'm validating a form on VIEW1 -> works perfect -> when validation is successful I do the following: Code: $this->load->view('header'); Ok so all goes well, my second view is shown, and I have stored the form data from VIEW1 in a session variable, so I can check if that form was already processed Now it goes wrong when validating this second VIEW. I do Code: if($this->validation->run() == FALSE) to validate my second view, with some new rules, but that never succeeds, since there are still errors showing up saying that my first VIEW form is not filled in (because this is not shown anymore)... Does anyone know if I can tell CI to just check for the $rules on my second form, and not my first form anymore? Here is my full controller code Code: <?php
[eluser]xwero[/eluser]
The code seems a bit strange. You don't check if there is post data so when you go to http://site.com/poll/create you are validating for the first time already? My take on your code is as follows Code: function create()
[eluser]jorre[/eluser]
Thanks a lot for correcting my newb-logic Can you tell me what the following does: if(count($_POST) > 0) -> does this check if any post happened? if(isset($_POST['step1'])) -> what is 'step1' in this code? Code is not working, but when you elaborate the above two rules, I'm sure I can figure it out. Thanks for not giving up an a OOP-newbie!
[eluser]xwero[/eluser]
Quote:if(count($_POST) > 0) -> does this check if any post happened?Yes Quote:if(isset($_POST[’step1’])) -> what is ‘step1’ in this code?It is the name of the submit. If you name the submit inputs you can distinguish actions on the same form but in this case it identifies the form.
[eluser]jorre[/eluser]
So it's <form name="step1"> that identifies the if(isset($_POST[’step1’])) ?
[eluser]xwero[/eluser]
no <input type="submit" name="step1" value="Proceed">
[eluser]jorre[/eluser]
Perfect, that makes good sense! Thanks a lot for this tip. I'm getting close, but right now I'm getting the following errors: A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Validation::$poll_topic_error Filename: views/pollcreate_step1.php Line Number: 3 I guess this is due to the fact that fields & rules are not setup unless the form has been posted. In my view I use code like <?=$this->validation->poll_topic_error; ?><br /> just as described in the userguide Is there a way to avoid this error ?
[eluser]xwero[/eluser]
You can set default validation values in your controller Code: $this->validation->poll_topic_error = ''; |
Welcome Guest, Not a member yet? Register Sign In |