php - Laravel Form Update can't get the right value -


so make laravel form update

index.blade

 <div class="col-sm-12">   <div class="formrow row">     <div class="form-group">       <div class="divlabel col-sm-2">       <label>kode program studi:</label>       <span class="required">*</span>     </div>     <div class="divinput col-sm-8">       <select id="id" data-plugin-selecttwo class="form-control populate placeholder" title="kode program studi harus diisi" name='id' required data-plugin-selectwo>         <option value="">-pilih nama user-</option>         @foreach ($users $user)           <option class="form-control" value = '{{$user->id}}'>{{$user->id.' | '.$user->name}}</option>         @endforeach         <label class="error" for="id"></label>     </select>     </div>   </div>    {!! form::open(['url' => 'master/hakakses/'.$user->id,'method' => 'patch','class'=>'update']) !!}   <!-- {!! form::model($user,['route'=>['master.hakakses.update', $user->id],'method' => 'patch','class'=>'update']) !!} -->     <div class="form-group">     <div class="divlabel col-sm-2">     <label>kode program studi:</label>     <span class="required">*</span>   </div>   <div class="divinput col-sm-8">     <select id="role" data-plugin-selecttwo class="form-control populate placeholder" title="kode program studi harus diisi" name='role_id' required data-plugin-selectwo>       <option value="">-pilih hak akses-</option>       @foreach ($roles $role)         <option class="form-control" value = '{{$role->id}}'>{{$role->id.' | '.$role->role_akses.' | '.$role->role_name}}</option>       @endforeach       <label class="error" for="role"></label>   </select>   </div> </div> </div> <div class="col-sm-offset-4 col-sm-50">     <input type="submit" value="ubah" name = 'simpan' class = 'btn btn-primary'>   <td><a href="{{ url('master/hakakses')}}" class="btn btn-primary">kembali</a></td> </div> </div>    {!! form::close() !!} 

controller :

public function index()     {         $data=new hakakses;          $users= $data->listuser();         $roles= $data->listrole();         return view ('master.hakakses.index',compact ('users','roles'));     }     public function update(request $request, $id)     {  return $id;      } 

model:

public static function listuser()     {       $table = db::select( db::raw("select * users"));       return $table;     }     public static function listrole()     {       $table = db::select( db::raw("select * m_role"));       return $table;     } 

the problem can't value of {{$role->id}} when try return $id , value latest input of id in database. think problem in form:

{!! form::open(['url' => 'master/hakakses/'.$user->id,'method' => 'patch','class'=>'update']) !!} 

can please me?

i see problem you're passing here:

{!! form::open(['url' => 'master/hakakses/'.$user->id,'method' => 'patch','class'=>'update']) !!} 

the $user->id want in controller {{$role->id}}

so solvation in controller to:

public function update(request $request, $id) {     // $id user's id      $roleid = $request->input('role_id'); } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -