Passing GET value show error |
hi , sorry for english :
i make a script to simulate a agenda , passing a data to a controller agenda/visualizza_settimana/day_of_week as (Y:m:d) show the week . Now i want search a data by a field type date , select a data and in my controller have $this->load->view('agenda/visualizza_settimana/'.$uk_date) but have this error : Unable to load the requested file: agenda/visualizza_settimana/2017-09-13.php , if i insert 2017-09-13 as parameter manually it work properly , why ? Work properly if i use redirect instead $this->load->view too.
A redirect loads a controller path and file, not a view file. A load->view loads a view file, not a controller, so you cannot pass a date to a view file in the url like that.
Your load command is looking for a file called agenda/visualizza_settimana/2017-09-13.php in your views folder. I am guessing that you need to load your view something like agenda/visualizza_settimana/day_view (no .php required) from your controller class called Agenda, with a method called visualizza_settimana which is expecting a variable like $date, that you use to collect the data for the day_view and then load the day_view. Agenda controller: PHP Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); day_view view file in a folder called 'agenda' inside the views folder, called day_view.php PHP Code: <h1>Day View</h1> Hope that helps, it seems complicated when you write it but it really is not. Paul.
(09-26-2017, 11:19 AM)PaulD Wrote: A redirect loads a controller path and file, not a view file. A load->view loads a view file, not a controller, so you cannot pass a date to a view file in the url like that. No , i dont understand , i have in another project the same problem : I have a controller Documentazione this is a function : Code: public function crea_documentazione_seconda($id) { I have also a view called : crea_documentazione_seconda.php in folder documentazione It need a GET value because if form_validation->run()=FALSE i have this problem : Message: Missing argument 1 for Documentazione::crea_documentazione_seconda() How can i solve ? (10-01-2017, 03:37 AM)pippuccio76 Wrote: this line of code has missing ); on the end. I presume this is a typo in posting the question. That message is just telling you that you are calling a controller with a missing argument. You are calling somewhere this function: PHP Code: crea_documentazione_seconda($id) I do not know where you are doing this. If I have misunderstood your problem I apologise in advance, Paul PS I find it useful to call my views and controllers things like: Dashboard.php (controller) dashboard_view.php (view file) Dashboard_model.php (model file) Dashboard_library.php (library file) etc.
(10-01-2017, 08:14 AM)PaulD Wrote:I see and know the error...(10-01-2017, 03:37 AM)pippuccio76 Wrote: I have this sistem because i have a list with all the record and have for every record a button : <a href='<?= base_url() ?>index.php/documentazione/crea_documentazione_seconda/<?= $row->id ?>' class='btn btn-primary btn-xs'><i class='fa fa-pencil'></i> Modifica Documentazione </a> (after other value in datatable) In this way when i push the button i can modify the record... There's a way to do this in another way
That seems a fair approach but you could use site_url instead, just a bit cleaner.
PHP Code: <a href='<?php echo site_url('documentazione/crea_documentazione_seconda/'.$row->id); ?>' class='btn btn-primary btn-xs'> If pressing that button is causing the missing argument, then just take a look at the html generated for the button and check the id is being found and is populated as you expected. Other than that I cannot debug your code, sorry. Paul PS Looking at your first post again, when you load a view file you are just loading a file, and sending it some data. You are not loading a controller into the view. PHP Code: $this->load->view('my_view_file', $page_data);
(10-01-2017, 08:46 AM)PaulD Wrote: That seems a fair approach but you could use site_url instead, just a bit cleaner. No with a pression of button the sistem work fine , the problem is when i submit the form without passing the form_validation and an argoment missing when loading $this->load->view('documentazione/crea_documentazione_seconda')
There must be something else going wrong with your code. A missing argument error is not a message you get with a view file, but with a controller. With a view file any missing data is displayed in the html as a php error.
(10-01-2017, 08:57 AM)PaulD Wrote: There must be something else going wrong with your code. A missing argument error is not a message you get with a view file, but with a controller. With a view file any missing data is displayed in the html as a php error. is simple , the method want an argument , when the form_validation is false this is the code : Code: $this->load->view('templates/header', $data); and the $id is not isset , but i want know if ther's an alternative way to do this....
Quote:[18:17:59] <Paradinight> form_open('documentazione/crea_documentazione_seconda/'.$res->id, $attributes); |
Welcome Guest, Not a member yet? Register Sign In |