PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, April 18, 2022

[FIXED] How do I display my error message as a link in Laravel

 April 18, 2022     eloquent, laravel, php     No comments   

Issue

I'm trying to create a validation such that if model_name is not unique, it will display a html link to view the existing model_name row. Something like this image, however my current code displays the message like this. What do I have to change in my code? Here's my code validation code:

'model_name.unique'=>'Model Already exists. <a href="'.route('view.models',[$request->model_name]).'">Go to page.</a>',

Thanks for any help.

Edit:

Here's the error part of my form:

<input type="text" name="model_name" class="form-control" id="exampleFormControlInput1" placeholder="Model Name">
                    @error('model_name')
                    <span class="text-danger">{{ $message }}</span>
                    @enderror
                   </div>

Solution

That escaped character. You can know more about it here and Laravel Docs.

So to be quick, you can try:

<input type="text" name="model_name" class="form-control" id="exampleFormControlInput1" placeholder="Model Name">
                @error('model_name')
                <span class="text-danger">{!! $message !!}</span>
                @enderror
               </div>


Answered By - Huy Phạm
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing