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

Php 如何将值从视图传递到模式?,php,laravel,bootstrap-modal,Php,Laravel,Bootstrap Modal,我在这里打开了以下链接: <li><a href="#deleteProperty{{$property->id}}" data-toggle="modal"><i class="fa fa-times"></i></a></li> 我在单独的页面modals.blade.php中有modal <div class="modal fade modal_form" id="deleteProperty{{$p

我在这里打开了以下链接:

<li><a href="#deleteProperty{{$property->id}}" data-toggle="modal"><i class="fa fa-times"></i></a></li>
  • 我在单独的页面modals.blade.php中有modal

    <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->id)传递给modal,以便用户单击特定属性时删除该属性?

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

    例如:

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

    您已经将该值传递给引导模式。这只是使用jQuery(?)的问题要访问
    .modal
    div的
    id
    属性,当我传递此值时,我得到一个错误未定义的变量属性您是否将属性传递给视图?是的…我可以访问视图中的属性您如何包括
    modals.blade.php
    页面?我不能这样做,因为在布局中我没有属性您需要重新考虑那你的策略呢。解析完所有属性后,您需要包含视图,或者应该使用
    view::share('property','$property)
    ,但这对于您的情况来说是一种糟糕的做法。