skip to Main Content

I have this dropdown i want to make it read only or disable

 {{ Form::select('name[]',$names,$name : '' ,['class'=>'form-control name input_fields','readonly'=>true,'id'=>'name']) }}

tried disabled also

 {{ Form::select('name[]',$names,$name : '' ,['class'=>'form-control name input_fields','disabled'=>true,'id'=>'name']) }}

but i want to disable options only the option that is pre-selected should be saved in database, using readonly i can change the dropdown and using disable i can’t get its value.

2

Answers


  1. This worked for me

    # assume "$names" as your data array, which comes from the backend
    @php
        $names = array('L' => 'Large', 'S' => 'Small')
    @endphp
    
    {{ Form::select('name[]',$names, '' ,['class'=>'form-control name input_fields','disabled'=>true,'id'=>'name']) }}
    

    In form remove "$names,$name : ''" and run only with $names array

    Login or Signup to reply.
  2. You have to use a hidden input

    Example based on your code ..

    {{ Form::select('name_placeholder', $names, $name , ['class'=>'form-control name input_fields', 'readonly'=>true,' id'=>'name']) }}
    {{ Form::hidden('name', $name) }}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search