Laravel study notes (31) Bootstraps part of the template study (modal, component)

  1. modal & component member

b4-modal-default

Note, form must be placed outside the table, otherwise it will submit no response.

<button data-toggle="modal" data-target="#modelId" type="button" class="btn btn-success">添加角色</button>
@component('components.modal', ['id'=>'modelId', 'title'=>'添加角色', 'url'=>'admin/role'])
    <div class="form-group">
        <label>Email_address</label>
        <input type="email" name="email" placeholder="[email protected]" class="form-control">
    </div>

    <div class="form-group">
        <label>Your name</label>
        <input type="text" name="name" placeholder="ABC" class="form-control">
    </div>
@endcomponent

{{$ Slot}} is a component locator

// view/components/modal.blade.php
<form action="{{$url}}" method="post">
    @csrf
    @isset($method)
        @method($method)
    @endisset
    <div id="{{$id}}" tabindex="-1" role="dialog" class="modal fade colored-header colored-header-primary show"
                   style="padding-right: 17px;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header modal-header-colored">
                    <h3 class="modal-title">
                        {{$title}}
                    </h3>
                    <button type="button" data-dismiss="modal" aria-hidden="true" class="close md-close"><span
                                class="mdi mdi-close">       </span></button>
                </div>
                <div class="modal-body">
                    {{$slot}}
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary md-close">保存</button>
                </div>
            </div>
        </div>
    </div>
</form>
Published 40 original articles · won praise 0 · Views 759

Guess you like

Origin blog.csdn.net/qj4865/article/details/104418443