How do I mount a select with two fields using colletivehtml in 5.5?

Asked

Viewed 250 times

1

Good afternoon.

I use Laravel 5.5 and for forms I use laravelcollective. I mount a select this way: $locals = Local::get()->pluck('codigolocal', 'id'); and the result is a select with the value = id and description equal to the code.

My problem is that I need to show beyond the code, also the description: Something like $locals = Local::get()->pluck(['codigolocal','descricaolocal'], 'id');

You can do this?

Thank you.

  • Which bank?

  • I use mysql 5.6

1 answer

1


  • See: It didn’t work:

  • Controller: {$locals = Local::selectRaw('id CONCAT(codigolocal," ",descricaolocal) as n')->Pluck('n','id'); $supplier = Supplier::get()->Pluck('Description', 'id'); $manufacturer = Manufacturer::get()->Pluck('Description', 'id'); Return view('admin.equipamento.create-Edit', Compact('title', 'centrocustos', 'typoequipamentos', 'typogas', 'locals', 'supplier', 'manufacturer'));}

  • And I call the view ː <div class="form-group"> Select Local {!! Form::select('local_id', $locals, ['class' => 'form-control']) !! } </div>}

  • Put all the controller on the question! and also which the message of the problem, This is to work yes @Marcosbirro

  • What is the error message @Marcosbirro and what didn’t work

  • 1

    OK. BUT IT WORKED OK. I made a change here and it worked. Thank you.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.