Laravel 7中的构建表单

问题描述 投票:0回答:2

我需要在Laravel Blade中构建表单。我是Laravel的初学者。我在我的项目Laravel 7中使用。我找到了组件:https://www.bgaze.fr/bootstrap-formv

可以吗?

我想在Bootstram 4中建立此表单:

<form method="POST"
      @if($page ?? false) action="{{ route('page.update', ['id' => $page->id ?? null]) }}"
      @else action="{{ route('page.store') }}" @endif class="form form-horizontal form-bordered">
    @if($page ?? false) @method('PUT') @endif
    {{ csrf_field()  }}

    <div class="box-body">
        <div class="form-group">
            <label for="title">Tytuł strony tekstowej*</label>
            <input id="title" type="text" name="title" required="required" maxlength="155" class="form-control"
                   placeholder="Wpisz tytuł strony tekstowej*" value="{{ $page->title ?? old('title') }}">
        </div>


        <div class="form-group">
            <label for="exampleInputEmail1">Treść strony tekstowej</label>
            <textarea class="form-control summernote" name="content" rows="3"
                      placeholder="Wpisz treść strony tekstowej">{{ $page->content ?? old('content') }}</textarea>
        </div>

        <div class="form-group size-200">
            <label for="exampleInputEmail1">Wpis aktywny</label>
            <label class="switch ">
                <input name="enable" value="1"
                       @if(!empty($page) && $page->enable == '1') checked="checked"
                       @endif  type="checkbox" class="primary" id="switch1"/>
                <span class="switcher round"></span>
            </label>
        </div>

        <div class="box-footer">
            <button type="submit"
                    class="btn btn-primary">Save
            </button>
        </div>
    </div>
</form>

如何在https://www.bgaze.fr/bootstrap-form中填写此表格?请给我一些这种形式的例子吗?我想基于此示例构建剩余的表单

[请帮助我:)

php laravel
2个回答
1
投票

您要做的所有事情:

  • 确保系统上已安装componser
  • 运行命令(在安装部分中)

    composer require bgaze / bootstrap-form

  • 就是这样,您现在可以将代码用作演示并从页面中的示例复制代码

    @ open(['novalidate'=> true])@text('登录')@email('email')@checkbox('remember_me',null,1,null,['switch'=> true,'inline'=> true])@submit('登录')@close


0
投票

您可以使用laravelcollective / html代替bgaze / bootstrap-form

示例:

{!! Form::open(array('route'=>array('users.create'), 'method'=>'post')) !!}
    <div class="form-group">
       {!! Form::label('name', 'Name:',['class'=>'control-label']) !!}
       {!! Form::text('name', '', array('id' => 'name','class'=>'form-control')) !!}
    </div>
    <button type="submit" class="btn btn-block btn-success">Save</button>
{!! Form::close() !!}
© www.soinside.com 2019 - 2024. All rights reserved.