Hello,
I need create a form with three selects.
These selects contains different values models.
How send more vector for a view.
I'm trying so:
//controller
public function create()
{
$departaments = \App\Departament::lists('name','id');
$places = \App\Place::lists('name','id');
$users = \App\User::lists('name','id');
$variaveis = ['departaments'=>$departaments,'places'=>$places,'users'=>$users];
return view('calls.create',compact('variaveis'));
}
and in view
<div class="form-group">
{!! Form::label('user','User:') !!}
{!! Form::select('user', $variaveis->users, ['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('departament','Departament:') !!}
{!! Form::select('departamet', $variaveis->departaments, ['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('place','Place:') !!}
{!! Form::select('place', $variaveis->places, ['class'=>'form-control']) !!}
</div>
but it 's happening the following error:
Trying to get property of non-object (View: /home/caio/cursos/laravel/laravel-chamados/resources/views/calls/_form.blade.php) (View: /home/caio/cursos/laravel/laravel-chamados/resources/views/calls/_form.blade.php)
That's because you are passing an array, not an object.
So you need to do this:
$variaveis['users']
This will not work:
$variaveis->users
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community