Second call to view with a form ignored by CI |
[eluser]ZoranM[/eluser]
Hi all, I am enjoying programming with CI for a few weeks and my first app is getting bigger and more functional every day. My controller is welcome.php, and my app is with two forms, simply saying cas_formular and cas_kontrola, and I am not using sessions (yet). First form, opened with Code: form_open('welcome/racunaj_cas') When first form is submitted to function racunaj_cas(), racunaj_cas() calculates all the sums and prepare all other variables taking values from other form fields and putting in a $data_cas array. Then it calls another view Code: $this->load->view('cas_kontrola', $data_cas); Code: form_open('welcome/upisi_u_bazu'); So, the program should run in the loop (I mean function upisi_u_bazu()) as long as there are empty requested fields nevertheless of submitted button. That control works fine, logic performs well: Code: if ($this->form_validation->run() == FALSE) My problem is that, when logic in function upisi_u_bazu() decides to call a view with a second form with refreshed data Code: $this->load->view('cas_kontrola', $data_cas); Is it allowed to call repeatedly view Code: $this->load->view('cas_kontrola', $data_cas); Code: form_open('welcome/upisi_u_bazu'); I am obviously missing something here, tried to search in forum with similar problem, googled it with no success. Please advise what am I doing wrong. Thanking you in advance, Best regards, Zoran
[eluser]InsiteFX[/eluser]
did you use a form_close on the end of your forms? InsiteFX
[eluser]ZoranM[/eluser]
I used Code: </form> Code: <?php echo form_close(); ?> Thanks for a try, Regards, Zoran
[eluser]kaejiavo[/eluser]
[quote author="ZoranM" date="1288118097"] Code: if ($this->form_validation->run() == FALSE) My problem is that, when logic in function upisi_u_bazu() decides to call a view with a second form with refreshed data Code: $this->load->view('cas_kontrola', $data_cas); [/quote] Hi, if you put the line with the echo "I Should..." after the load->view line, it will always be executed - Even if your view is perfectly loaded. (I tested it right now) So, what happens if you leave this away? Marco
[eluser]ZoranM[/eluser]
I commented out that echo, problem persists. There is same behavior with this part of the program: Code: $check = $_POST['pritisnuto']; Code: <div><input type="submit" name="pritisnuto" value="Check" /> This call too does not work Code: $this->load->view('cas_kontrola', $data_cas);
[eluser]InsiteFX[/eluser]
It could be that you are losing the data between function calls! Read this: CodeIgniter User Guide - Flashdata InsiteFX
[eluser]ZoranM[/eluser]
[quote author="InsiteFX" date="1288123717"]It could be that you are losing the data between function calls! Read this: CodeIgniter User Guide - Flashdata InsiteFX[/quote] Thanks InsiteFX, I am not sure if I follow you: data is prepared in function which calls view with a form which then shows sent data. It works well every first call. But with second call no form is displayed. If data was lost, forms would be shown empty, right? But in my case forms are not shown at all, execution just passes those calls further like these calls don't exist. Thanks again for a try, Zoran
[eluser]ZoranM[/eluser]
Few minutes ago, one detail in calling the views came in my sight: in every working part, call of the view as at the end of the function. In these parts with a problem, these calls are under if statement and certainly function does not end with them - that was the real cause of the problem. So, what I did to try to correct my problem is to make same thing in these function: after call of the view, function will come to an end which was possible thanks to else statement: Code: if ($this->form_validation->run() == FALSE) So, it works fine now. Thanks to all who tried to help. Once more it is proven that we, who ask for help, did not do everything by the book )))) Best regards, Zoran PS Dunno how to mark this post as SOLVED. |
Welcome Guest, Not a member yet? Register Sign In |