如何将值从视图传递到模态?

时间:2016-11-08 10:48:49

标签: php laravel bootstrap-modal

我有这个链接,我打开模态:

<li><a href="#deleteProperty{{$property->id}}" data-toggle="modal"><i class="fa fa-times"></i></a></li>

我在单独的页面modals.blade.php

中有模态
<div class="modal fade modal_form" id="deleteProperty{{$property->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel5" aria-hidden="true">
              <div class="modal-dialog" role="document">
                  <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                              <span aria-hidden="true">&times;</span>
                          </button>
                          <h4 class="modal-title" id="exampleModalLabel5">Are you sure you want to delete this property?</h4>
                      </div>
                      <div class="modal-body">
                      <form method="POST" action="{{ route('user.property.delete',[$user->id,$property->id])}}">
                          <div class="form-group">
                            <div class="left-btn">
                                <button type="button" class="btn btn-primary" data-dismiss="modal">No</button>
                            </div>
                            <div class="right-btn">
                                  <button type="submit" class="btn btn-primary">Yes</button>
                            </div>
                          </div>
                      </form>
                      </div>
                  </div>
              </div>
          </div>

如何将此参数($ property-&gt; id)传递给模态,以便当用户点击特定属性时删除该属性?

1 个答案:

答案 0 :(得分:1)

您需要在包含的视图中传递要使用的变量。

示例:

@include('standardUser.includes.modals', [ "property" => $property ])