ycs77 / laravel-wizard

A web Setup Wizard for Laravel application.
MIT License
122 stars 18 forks source link

SaveData function issue #43

Closed thakurdinesh2 closed 1 year ago

thakurdinesh2 commented 1 year ago

Use Version: Use version when bugs appear.

Describe the bug Try to call curl request and get some errors. Is there any way to stop on same step with errors ?

To Reproduce Provide some code here to reproduce the bug.

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

ycs77 commented 1 year ago

Hi @thakurdinesh2, you can follow the steps:

  1. First you must disable the wizard cache option on your WizardController, and let the saveData() method called on after each step:

    class UserWizardController extends Controller
    {
        use Wizardable;
    
        protected $wizardOptions = [
            'cache' => false,
        ];
    }
  2. Throw the ValidationException when the CURL error throws in the Step class, then will show the error message under the name field:

    class NameStep extends Step
    {
        public function saveData(Request $request, $data = null, $model = null)
        {
            throw ValidationException::withMessages([
                'name' => 'The CURL request has some error.',
            ]);
        }
    }

You can try it~