Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set disabled select option in Laravel with Illuminate/Html

I'm starting with Laravel and I'm using Illuminate/Html for making forms.

I want to add disabled attribute to the first option and I dont find the way to do it.

{!! Form::open(['url' => 'shelter/pets']) !!}
    <div class="form-group">
        {!! Form::label('pet_type','Type:') !!}
        {!! Form::select('pet_type', ['Select Type','dog', 'cat'], 0, ['class' => 'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::submit('Add pet', null, ['class' => 'btn btn-primary form-control']) !!}
    </div>
{!! Form::close() !!}
like image 542
bigbiggerpepe Avatar asked Dec 20 '22 04:12

bigbiggerpepe


1 Answers

Just pass the disabled in the options. Try with -

{!! Form::select('pet_type', ['Select Type','dog', 'cat'], 0, ['class' => 'form-control', 'disabled' => true]) !!}

You can do it manually looping through the array in php or by using jquery.

$('select.someclass option:first').attr('disabled', true);
like image 116
Sougata Bose Avatar answered Dec 24 '22 02:12

Sougata Bose