Welcome Guest, Not a member yet? Register   Sign In
Validation in controller for "patch" request
#1

Hello!
I want to add "update" action to controller as patch.
I've created this test:
PHP Code:
$attributes = ['title' => 'Changed Title'];
$response $this->patch(route_to('project.update'1), $attributes); 

Now the only method to retrieve data in controller is:
PHP Code:
$this->request->getVar(['title']); 

I.e. data are not in POST array. This is ok until I try to run validation:
PHP Code:
$this->validate(['title' => 'required|min_length[3]|max_length[128]']);
$e $this->validator->getErrors(); 

Now $e has message that "The title field is required". I.e. validation does not see passed data.
When I change action type to post it works as expected.
Is there any way to implement validation for patch or I have to use post? What are correct tests if patch can be used?
Reply


Messages In This Thread
Validation in controller for "patch" request - by Taras - 08-18-2021, 12:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB