Search code examples
phplaravellaravel-5laravelcollective

Form dropdown menu passing array as object


I'm trying to pass trough form dropdown selection but I can't pass array(the rest of the form is using objects. This is my code

Controller

$var->user = $request->users->id;

view

{!! Form::select('users', $users,null, ['placeholder' => 'Pick a user']) !!}

One solution is converting array to object using eloquent, how can that be done


Solution

  • If you want to get selected user's ID, I guess you need to do this:

    $request->users
    

    You're getting "Trying to get property of non-object" error, because $request->users is not an object.