How to put 3 parameters in input value? Laravel 5.7

Asked

Viewed 261 times

-1

I need to put a default value in a text input.

The default value will be 'Brazil', but I’m using the old helper in Blade and I don’t know how to enter this default value. the code I’m using is this.

<input type="text" name="address_province" value="{{ old('address_province', @$geral->address_province) }}">

I tried to use the or after the value of the variable $geral, but it didn’t work.

1 answer

0


After searching a little, I found a solution that met my problem, just enter in the value a third parameter using the ternary operator ?:.

Example.

<input type="text" name="address_province" value="{{ old('address_province', @$geral->address_province) ?: 'Portugal' }}">

Using the ternary operator it was possible to insert another value for the value of input, because it checks for data in the helper old() and if not find execute what comes after the ?:.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.