Support the ongoing development of Laravel.io →
Blade Forms

Hi, is there a possibility to put an HTML Attribute depending on whether or not a condition is true? Let say I would like to make the checked and disabled attributes conditional, how do I do that?

<input type="radio" checked disabled name="obj->name" value="{{$obj->id}}">{{$obj->title}}
Last updated 2 years ago.
0
Solution

Maybe

<input type="radio" {{ $somethingtocheck ? 'checked disabled' : '' }} ....>
0

try this

<input type="radio" {{ ( $something == 'condition' ) ? 'checked' : 'disabled' }} ... >
Last updated 8 years ago.
0

Thank You very much - works

0

Sign in to participate in this thread!

Eventy

Your banner here too?

sixthpack sixthpack Joined 6 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.