jeudi 29 octobre 2015

Laravel 5.1 formfacade can't get value from select

I have created a form to change the user name and its role in the website.

@extends('layout/layoutAdmin')
@section('content')
<div>
  <h1>{{ $user -> name }}<h1>
  <p>{{ $user -> email }}<p>
</div>
{!! Form::model($user, ['url' => 'admin/menu/user_profiles/' . $user->id,  'method' => 'PATCH']) !!}
<div class="row">
<div class ="form-group">
    {!! Form::label('name', 'Name:') !!}
    {!! Form::text('name', $user->name,['class' => 'form-control']) !!}
</div>
<div class="form-group">
   {!! Form::label('role', 'Role:') !!}
   {!! Form::select('role', array('admin' => 'admin', 'super_admin' => 'super admin',
   'super_researcher' => 'super researcher', 'researcher' => 'researcher',
   'consultant' => 'consultant', 'user' => 'user'), $user->role)
    !!}
 </div>
 <div class="form-group col-xs-8 col-md-7">
   {!! Form::submit('Update', ['class' => 'btn btn-primary']) !!}
 </div>
</div>
{!! Form::close() !!}

@stop

Everything is correct with the controller and I can change the name just fine, but I cannot save a new value for the role. it always stays the same. Could anyone tell me how to save the role value?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire