scoumbourdis / grocery-crud-codeigniter-4

GNU General Public License v3.0
68 stars 38 forks source link

Question: Setting correct routes for actions #6

Closed sfadschm closed 4 years ago

sfadschm commented 4 years ago

Hey Johnny, could you add a little documentation on setting correct routes for the actions (like 'edit', 'update' etc.)?

Maybe I just didn't quite get the routes principles of CI4 with groceryCRUD, however, here is what is working for me to some extend:

$routes->get('(:segment)/add', '$1::index'); $routes->get('(:segment)/edit/(:num)', '$1::index'); $routes->match(['get', 'post'], '(:segment)/update/(:num)', '$1::index');

These routes work so far as they display the CRUD table, the edit forms, add forms and they allow updating values in the database from the 'edit' view. However, the (JSON) success messages generated from updating datasets are simply echoed by the set_echo_and_die() function for me instead of getting embedded into the corresponding template.

Am I missing out on the concept of routing here or is this not yet implemented in the new gC version?

Thank you for the great work :) Cheers, Alex

sfadschm commented 4 years ago

I just realized that setting

->setApiUrlPath('.../index')

removes the need to define all these routes. This one is on me...

However, the result messages are still simply printed as a JS string.

sfadschm commented 4 years ago

Nevermind, should have paid attention to including the JS files the right way...