J
J
Jedi2018-04-07 03:13:03
Laravel
Jedi, 2018-04-07 03:13:03

How to output select attribute via ternary operator in Blade templating engine?

{{ $user->gender == 0 ? 'selected' : '' }}
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zlatoslav Desyatnikov, 2018-05-19
@PHPjedi

The above example should work.
In general, if you use a lot of forms and their elements, then there is a wonderful package (which once spun off from Laravel) - https://laravelcollective.com/docs/5.4/html
Allows you to create a select like this:
In this example, the third parameter is the selected value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question