I am beginner in Laravel. I use in my project. Laravel 7 and https://www.bgaze.fr/bootstrap-form#forms.
I have this form:
<form method="POST"
@if($page ?? '' ?? false) action=""
@else action="" @endif class="form form-horizontal form-bordered">
@if($page ?? '' ?? false) @method('PUT') @endif
<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="">
</div>
<div class="form-group">
<label for="description">Description</label>
<input id="description" type="text" name="description" maxlength="155"
class="form-control"
placeholder="Wpisz description" value="">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Keywords</label>
<input id="keywords" type="text" name="keywords" maxlength="155" class="form-control"
placeholder="Wpisz keywords" value="">
</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"></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">Zapisz</button>
</div>
</div>
</form>
I'm trying write it in bootstrap-form:
@open(['store' => ['page.store'], 'update' => ['page.update', ['id' => $page->id ?? '']], 'method' => 'POST', 'class' => 'users-search-form', 'novalidate' => env('FORM_VALIDATE')])
@text('title', 'Tytuł strony tekstowej*', $page->title ?? old('title'), ['id'=>'id', 'class'=>'form-control', 'required'=>true, 'placeholder'=>'Wpisz tytuł strony', 'maxlength'=>155])
@text('description', 'Description', $page->description ?? old('description'), ['id'=>'id', 'class'=>'form-control', 'placeholder'=>'Wpisz description strony', 'maxlength'=>155])
@text('keywords', 'Keywords', $page->keywords ?? old('keywords'), ['id'=>'id', 'class'=>'form-control', 'placeholder'=>'Wpisz keywords strony', 'maxlength'=>155])
@textarea('content', 'Treść strony', $page->content ?? old('content'), ['id'=>'id', 'class'=>'form-control summernote'])
@checkbox('name', 'Wpis aktywny', 1, ($page->enable == 1 ? true : false) ?? '', ['switch' => true, 'inline' => true, 'group' => true])
@submit('Zapisz')
@close
I have some questions and problems: 1. My form URL is always pages / create. - not page.store (when creating a new page) or page.update (when editing) 2. I'd like to have the POST method for page.save and PUT for updates (page.update) 3. Generally, is my code correct? $ page-> id ?? '' - is required?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire