I was testing this new Laravel fortify with Laravel 8 and got into an odd issue that I've never seen before.
for the input field validation of the registration form and login form, the blade error message that I made doesn't show if I don't use #error('[field name]') is-invalid #enderror to add the is-invalid class to the input field.
any idea why is that?
this is how I'm showing the error:
#error('[field name]')
<span class="invalid-feedback is-invalid" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
Here id the demo code I made:
https://gitlab.com/sxshateri/laravel-fortify
Related
I want to show validation errors right next to the field.
Therefore I am using this the #error directive.
#error('service_date')
<div class="error">{{ $message }}</div>
#enderror
But the error only shows up when iterating over all of them.
#if($errors->any())
{{ implode('', $errors->all('<div>:key - :message</div>')) }}
#endif
Using the above method, I can see that the key is correct. The output will be as follows:
service_date - The service date is not a valid date.
Other errors in the same form get displayed correctly. Why is behaving like this and how can I fix it?
Why won't error message display with the code below?
I can see the error message in page source code though.
#if($errors->has('slug'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('slug')}}</strong>
</span>
#endif
However this works:
#if($errors->has('slug'))
<p>{{ $errors->first('slug')}}</p>
#endif
The class "invalid-feedback" has display none in bootstrap 4.
You can add the class "d-block" to display it "invalid-feedback d-block"
Hello i am using laravel 5.7.15
i am facing issue
<form method="post" action="my_post_Action" class="login100-form validate-form">
<input type="hidden" name="_token" value="B6et9cJOP5wNKodCPgCbAafDjpA5EMcRaaJhEJ9F">
<span class="login100-form-title">
Admin Login
</span>
<div class="wrap-input100 validate-input" data-validate="Valid email is required: ex#abc.xyz">
<input class="input100" type="text" name="email" placeholder="Email">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-envelope" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<input class="input100" type="password" name="password" placeholder="Password">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-lock" aria-hidden="true"></i>
</span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
Login
</button>
</div>
</form>
here is my code
i don't know whats error
it my login route if i comment csrf verification form kernal.php then session not work
Any Help thanks in advance ..
Make sure you hard refresh the page; Clear the cache as well by doing:
php artisan cache:clear
Make sure you have the right permissions for your logs folder:
chmod -R 755 storage/logs
Make sure to generate a key for your application:
php artisan key:generate
Check if, when using post and CSRF you have the web middleware group wrapping your routes;
I solved mine with that! Hope it helps! :D
Try to put #csrf in bottom of <form> tag
It's one time only? Just delete the folder storage/framework/cache/data
You have to set chmod to 757 for ./storage/framework/sessions also.
It helps for me and it works fine now, without error 419.
Anytime you define an HTML form in your application, you should include a hidden CSRF token field in the form so that the CSRF protection middleware can validate the request.
Try #csrf after tag.
Just in case of dispair and when no other solution Works , you can add your page name here to a White list to the pages that will not be checked with CSRF.
Needless to say , is a must to remember that with this you are removing this security check , use it wisely and at your own criteria
you can find it here : app/Http/Middleware/VerifyCsrfToken.php
/**
* The URIs that should be excluded from CSRF verification.
*
* #var array
*/
protected $except = [
'/nameofpagetobeexcluded','/anotherpagetobeexcludedfromthischeck'
];
Make sure you have added #csrf OR {{ csrf_field() }} in your form.
<form method="post" action="{{ url('your route here') }}">
#csrf
</form>
i had faced same issue and i solved my issue by adding #csrf inside to form
Like:
<form method="post" action="{{.....}}">
#csrf
.....
</form>
I do not really got the issue I have tried every solution
but i have to install new Laravel and have to move all my Controllers, Routes, And views manually to get rid of the issue Really thanks to all of you guys
:)
I get the error in the title sometimes but when I refresh a few times, my application works again.
Laravel.log shows this:
[2016-12-19 13:17:22] local.ERROR: exception 'ErrorException' with
message 'Trying to get property of non-object' in
storage\framework\views\e81b4a67320194ba9a4782ec91b02d51:12
storage/framework/views/e81b4a67320194ba9a4782ec91b02d51.php line 12:
<span class="block m-t-xs">
<strong class="font-bold"><?php echo e(Auth::user()->name); ?></strong> <!--line 12-->
</span>
do Auth::check() or Auth::user() before trying to access fields in user object. Its because that you are trying to get a property of the user object, but the user object is null. like this
<span class="block m-t-xs">
#if(Auth::check())
<strong class="font-bold">
{{ Auth::user()->name }}
</strong>
#endif
</span>
For some reason Auth::check() returned false but app didn't log me out. After clearing cookies and logging in again this error stopped happening.
I suspect the issue was that I changed the user and auth quite a bit but didn't clear cookies
You should check if the session has the authenticated user or not using auth()->check():
<span class="block m-t-xs">
<strong class="font-bold">
<?php echo (auth()->check()) ? e(Auth::user()->name) : ''; ?>
</strong>
</span>
You can use ternary operator to check if the user is authenticated or not.
Hope this helps!
Why you 're trying to use e()? try to dd(Auth::user()) then see the result or try
{{ Auth::user()->name }}
I'm using Laravel 5.1 and the built-in auth functionality. When testing it, however, I noticed there is no "Success" message when a user fills out the forgotten password form, the page simply refreshes, although the form does work.
How can I set a success variable for the forgotten password tool? I can't find the method that controls this anywhere.
Thanks
If you’re using Laravel’s built-in password reset functionality, then it does have a success message. You can see it here: https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Auth/ResetsPasswords.php#L95
You merely need to listen for it in your view and display it if it’s there:
#if (session('status'))
<p class="alert alert-success">{{ session('status') }}</p>
#endif
This will display the default message, which is:
Your password has been reset!
If you want to change this message, just change the relevant line in resources/lang/en/passwords.php.
Simply paste this function in your ResetPasswordController
protected function sendResetResponse(Request $request, $response)
{
return redirect($this->redirectPath())
->with('success', 'Password changed successfully.');
}
And to get the message in your blade view, use this code
#if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
#endif