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

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:

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?

Ok, I've found solution. I have to run validation manually supplying data gathered with getVar.

PUT does this automatically though. But it that case I have some troubles in creating test request with $this->put() as passing data in array doesn't work. It would be nice to have all these methods to work in a same way.

Theme © iAndrew 2016 - Forum software by © MyBB