Skip to content

Alert title and message blank when using redirect()->withErrors() #130

@hakimzulkufli

Description

@hakimzulkufli

Description

Alert title and message blank when using redirect()-back()->withErrors($validator). Perhaps I am doing this wrong? I would like to skip the usage of Middleware if possible. See the image below:

image

Package Version: 2.0.5
Laravel Version: 6.18.41

Steps to Reproduce

  1. Use a validator() helper to validate $request.
  2. On validator()->fails(), call alert() helper. (Usage of alert() helper of the SweetAlert facade does not matter as neither works.)
  3. Use redirect()-back()->withErrors($validator) after alert() helper.

Sample Code

public function store(Request $request)
{
        $validator = validator()->make($request->all(), [
            'name' => 'required|string'
        ]);

        if($validator->fails()) {
            alert()->error(__('Please check your entries and submit again.'), __('Invalid Submission'))->persistent('OK');

            return redirect()->back()
                ->withInput()
                ->withErrors($validator);
        }

        // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions