Read works, add, edit, delete, not in the grocery library Crud Codeigniter

I made an example and installed everything.

The method of reading or displaying the table works correctly, but whenever I try to add, delete or modify the registry, windows will appear and say:

404 Page Not Found

The page you requested was not found.

Here is my controller

class Welcome extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('grocery_CRUD_model');
        $this->load->database();
        $this->load->helper('url');
        $this->load->library('grocery_CRUD');
    }


    public function index()
    {
        $crud = new grocery_CRUD();

        $crud->set_theme('datatables');
        $crud->set_table('students');
        $crud->set_relation('class','class','class');
        $crud->display_as('name','Name of Student');
        $crud->set_subject('Students');
        $crud->columns('name','class','roll_no');
        $crud->add_fields('name','class','roll_no');
        $crud->required_fields('name','class','roll_no');
        $crud->unset_export();
        $crud->unset_print();
        $output = $crud->render();
        $this->load->view('home', $output);

    }

}

when I click the URL of the ADD button, it becomes

http://localhost/index.php/add

what is missing I'm new to codeigniter and Grocery Crud ...

+4
source share
1 answer

Create another function in the controller Welcomeand move all the code from the function index()to a new function, for example:

public function myFunction()
    {
        $crud = new grocery_CRUD();

        $crud->set_theme('datatables');
        $crud->set_table('students');
        $crud->set_relation('class','class','class');
        $crud->display_as('name','Name of Student');
        $crud->set_subject('Students');
        $crud->columns('name','class','roll_no');
        $crud->add_fields('name','class','roll_no');
        $crud->required_fields('name','class','roll_no');
        $crud->unset_export();
        $crud->unset_print();
        $output = $crud->render();
        $this->load->view('home', $output);

    }

And redirect the function index()to this method:

public function index()
    {   
        redirect("welcome/myFunction");
    }

http://localhost/index.php/welcome/newFunction

http://localhost/index.php/welcome

.

+3

Source: https://habr.com/ru/post/1536426/


All Articles