-2
I am trying to bring a select already selected according to the information that is recorded in the bank. However I am having a lot of difficulty. I’ll leave the code below.
Controler
public function ListaUf()
{
$ListaUf = Estado::all();
return view(‘psicologo’,compact(‘ListaUf’));
}
Routes
Route::get(’/psicologo/editar/{psi_codigo}’,‘ControladorMunicipioUf@ListaUf’);
View
<select>
@foreach($ListaUf as $uf)
<option {{$psi->uf_codigo=={{$uf->uf_codigo}} ? 'selected':''}} value="{{$uf->uf_codigo}}">{{$uf->uf_estado}}</option>
@endforeach
</select>
Are you making a mistake? Where specifically is the difficulty?
– sant0will
I modified the code. it’s like this now.
– user9078159
Try to change
{{$psi->uf_codigo=={{$uf->uf_codigo}} ? 'selected':''}}
for{{$psi->uf_codigo == $uf->uf_codigo ? 'selected' : ''}}
– adventistaam