在叶片发动机拉拉威尔中固定模态和形式

时间:2020-02-25 13:31:55

标签: laravel security laravel-blade

您如何保护模态数据不暴露在刀片模板中,只是想知道我如何保护我的模态表单不暴露例如。路线,id等。当我检查元素或查看页面源代码时,它将显示包括输入的id和值在内的整个表单,例如,如果您有任何我可以阅读的有关该问题的文章,请与我分享,谢谢

从查看页面源输出 enter image description here

模式视图

@if(count($editor)==1)
<form method="POST" action="{{route('edit.member',$member->pivot->token)}}">
@csrf
@method('PUT')
<div class="modal fade EditMemberModal" id="EditMemberModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Edit Role</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
          <div class="form-group">
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text">Current Role</span>
              </div>
              <input type="text" class="form-control" id="role" disabled>
            </div>
            <div class="input-group mb-3">
             <div class="input-group-prepend">
               <label class="input-group-text" for="inputGroupSelect01">New Role</label>
             </div>
             <select class="custom-select" id="inputGroupSelect01" name="role">
               <option value="member">Member</option>
               <option value="editor">Editor</option>
             </select>
           </div>
            <input type="hidden" class="form-control" id="user" name="user_id">
            <input type="hidden" class="form-control" id="group" name="group_id">
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
</form>    
@endif
<!--===========================Edit Modal For Members==========================-->

1 个答案:

答案 0 :(得分:1)

如评论中所述,您无法隐藏用于填充刀片模板的任何内容。

一旦服务器生成并发送给客户端,客户端就可以使用您的模板执行他们想要的操作。这包括更改输入字段的名称,隐藏的输入字段的值以及表单操作的路径。

您应该关注的是表单验证,既可以在HTML表单上进行,也可以在服务器端进行。

Laravel附带了Validator,并具有创建自定义Request对象的能力。

可以在Laravel文档here

中找到该文档。

如果您想走得更远,请按@Jeremy Harris提到的输入字段别名。然后,您可以将它们映射到Controllers中的数据库列。