![]() |
put method not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: put method not working (/showthread.php?tid=75831) |
put method not working - cilux - 03-21-2020 I have this route for update my user data: PHP Code: $routes->put('/admin/users/(:num)/update', 'Admin\UserController::update/$1', ['as' => 'update']); in UserController: PHP Code: public function update(int $id){ in View: PHP Code: <form method="PUT" action="<?= route_to('update', esc($user['id'])); ?>" > But in Action i see error: Code: 404 - File Not Found How do can i fox this problem? RE: put method not working - jreklund - 03-21-2020 Have you checked the generated source code for your action="". Where does it go? RE: put method not working - cilux - 03-23-2020 (03-21-2020, 07:51 AM)jreklund Wrote: Have you checked the generated source code for your action="". Where does it go? Yes, when i change/replace put to post(in routes and form action) every thing is ok and work but in put method i see this error. RE: put method not working - kilishan - 03-23-2020 HTML forms don't really do PUT requests. PUT requests are typically handled through AJAX requests, but CI4 does provide HTTP method spoofing you can use with your forms to emulate it. Note, that it's still a POST request and any request variables would still be accessible through $_POST, not the request body like an actual PUT request would do. RE: put method not working - blaasvaer - 12-15-2020 Well, that may be so. But I can't seem to make a put request using jquery (type = PUT) either. The docs aren't to clear on how to actually 'use' what it tries to explain. I set a route (… ->put …) and expect to be able to do 'automatic' updates on resources, as that's the impression I get from reading up on "RESTful Resource Handling" ... Could you maybe be a bit clearer on the full 'lifecycle' – if you will – on how to properly implement a RESTFul API using the provided 'tools' in CI4? What would be nice is a set of routes matched to a set of methods, matched to a set of url requests with the corresponding data set properly using the matched HTTP methods. It seems I have to do A LOT of assembling the puzzle pieces myself ... to much is assumed, I guess. |