doucheng3811 2017-08-16 09:19
浏览 19
已采纳

Laravel用户编辑

I have user details from DB and print using blade loop with button for edit. now I want, if I click button I need user details for the button which is clicked for user.

i tried with hidden input filed <input type="hidden" value="{{$user->email}}" name="email"> in my controller I just print the value from form submit. but I am getting only last user.

See below, I hope you will understand..

<div class="content-wrapper">
    <div class="flex-center position-ref full-height">
        <form action="{!!url('/delete')!!}" method="post"> {!!csrf_field()!!}   
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                      <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Role</th>
                      </tr>
                    </thead>
                    <tbody>
                   @foreach($users as $user)
                      <tr>
                        <td>{{$user->id}}</td>
                        <td>{{$user->name}}</td>
                        <td>{{$user->email}}</td>   <input type="hidden" value="{{$user->email}}" name="email">
                        <td>{{$user->role}}</td>
                        <td>
                            <div class="btn-group">
                              <button type="submit" class="btn btn-primary btn-sm" name="edit"  >Edit</button>
                              <button type="submit" class="btn btn-primary btn-sm" name="delete"    >Delete</button>
                              <button type="submit" class="btn btn-primary btn-sm" name="make"  >Make Admin</button>
                            </div>
                        </td>
                      </tr>
                    @endforeach
                </tbody>
                </table>
            </div>  
        </form>     
    </div>
</div>  
  • 写回答

2条回答 默认 最新

  • doulizhi1247 2017-08-16 10:16
    关注

    Assuming that you want to go to edit page with a user's details when you click edit button.

    <a href="{{ route('your_route_name',$user->id) }}" class="test-btn btn btn-primary btn-sm">Edit</a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM