jeudi 2 janvier 2020

Default selected

I want to show the full time as a default selected in dropdown. The coding I need to alter is not showing the value, is suppose to be select the full time as default:

enter image description here

this is the data:

enter image description here

This is the coding:

<div class="form-group">
      <label class="col-lg-2 control-label"></label>
      <div class="col-lg-6">
        {!! Form::dropdown('program['.$i.'][study_mode_id]', $study_mode, @$student_program[$i]->study_mode_id,'class="select2-form" ') !!}
      </div>
    </div>

This is the helpers I use:

 public static function dropdown($name = 'dropdown', $option, $value = ' ', $additional = '')
    {
        $classmsg   = "form-control";
        $additional = Forms::additional($additional, $classmsg);

        // if (is_array($option)){
        //     if ($value != '' &&  !array_key_exists($value, $option))
        //     {
        //         $option[$value] = '*data is not available (use this if not intend to change)';
        //     }
        // }
        // else{
        //     if ($value != '' &&  !array_key_exists($value, $option->pluck('id')->toArray()))
        //     {
        //         $option_object = (object) array('id' => $value, 'name' => '*data is not available (use this if not intend to change)');
        //         $option->push($option_object);
        //     }
        // }

        $data = array(
            'name'    => $name,
            'option'  => $option,
            // 'value' => array($value),
            'value'   => ($value !== '') ? array($value) : $value,
            'extra'   => $additional['extra'],
            'class'   => $additional['class'],
            'type'    => '',
            'select2' => 'select2-filter',
        );

        return view('widget.form_dropdown')->with($data)->render();
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire