inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.08k stars 234 forks source link

Errors bag is not returned from Laravel when making partial reload using only prop #532

Closed carauzs closed 1 year ago

carauzs commented 1 year ago

I don't know if this is a bug or if it is the expected behavior. If you send only prop using the inertiajs router, Inertia throws away all shared data, including validation errors, I would expect to receive the requested data from the controller and also the validation errors if exist.

web.php

Route::post('/', [TestController::class, 'test'])->name('test');
ValidationRequest.php

class ValidationRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'field' => 'required'
        ];
    }
}
TestController.php

public function test(ValidationRequest $request) {
return [];
}
router.post(route('test'), {
            ...data,
        }, {
            preserveScroll: true,
            only: ['test']
        });
jessarcher commented 1 year ago

Thanks for the report! It's being discussed further at https://github.com/inertiajs/inertia/issues/1639 (I realise your issue was first).