mercredi 15 janvier 2020

Laravel old() directive with conditional default value

I'm using Laravel 5.8, and have several input fields which of course has an old() directive on every value="" tag.

This is my example right now:

<input class="form-control input-md" name="contact_name" type="text" value="@if($edit)@else@endif">

I now that if I use this:

The default value will be "John"

But I want to do a check if there is a user logged in and prefill that input with the User contact name.

My idea is something like this:

value="@if($edit)@else@endif

And it works! But of course, it throws: Trying to get property 'name' when I get an incognito window.

So, how do I evaluate logged in users and prefill this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35TUMf1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire