Using @error directive to target the previous input field from multiple input fields after submit in Laravel 5.8

后端 未结 2 1671
轮回少年
轮回少年 2021-01-27 13:12

The new @error directive was introduced in Laravel 5.8.13. So, instead of doing this:

// old
@if ($errors->has(\'emai         


        
2条回答
  •  不知归路
    2021-01-27 13:57

    A solution would be doing the following:

    • store the value / posted form in a variable using the value of the submit button
    • ditch the error directive and use the old version
    • combine the old version with the variable to check wether you have the correct form or not

    You'll get something like this:

    @if ($errors->has('email') && $submitted_form_identifier === $form_identifier) 
        {{ $errors->first('email') }} 
    @endif
    

提交回复
热议问题