Laravel admin panel may throw 302 error when you submit a form. This error is not directly reported on the console or on the form page.
The error maybe reported as
This is kind of confusing error that we got.
Since we are using a third party package, the error reporting did not give enough info. One of the issue caused this is form submission.
If our case we are using form method to submit a form. Let's took at an example
protected function form()
{
$form = new Form(new Course());
$form->text('name',__('Name'));
$result=CourseType::pluck('title','id');
$form->select('type_id',__('Category'))->options($result);
$form->image('thumbnail',__('Thumbnail'))->uniqueName();
$form->file('video',__('Video'))->uniqueName();
$form->text('description',__('Description'));
$form->decimal('price',__('Price'));
$form->number('lesson_num',__('Lesson Num'));
$form->number('video_length',__('Video Length'));
$result=User::pluck('name','token');
$form->select('user_token',__('Teacher'))->options($result);
$form->display('created_at',__('Created at'));
$form->display('updated_at',__('Updated at'));
return $form;
}
Here we are submitting form through $form object. It tries to submit each form fields like text, image, title, file, number. All the fields to be submitted.
But this form submission goes through Repsonse class which uses setStatusCode function. It checks whether every field in the form matches the database field.
If not it returns
Remove the unnecessary fields not in database, you would be good to go. In my case I was submitting lesson_num and video_length. But they did not exist as columns in the database fields. So I was getting the error.
Infact it's 302 error. Remove unncessary database fields if you laravel admin package.