Support the ongoing development of Laravel.io →
Views Blade

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)

Last updated 2 years ago.
0

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
0

Thanks Thomastkim

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.