Last active
February 8, 2020 17:03
-
-
Save skadimoolam/f2afa4a2a036ce62e0280be056d164de to your computer and use it in GitHub Desktop.
Customizable form partials for Laravel - https://laravelcollections.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
$d = $d ?? null; // default value | |
@endphp | |
<div class="form-group row"> | |
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label> | |
<div class="col-md-8"> | |
<input id="{{ $n }}" type="checkbox" class="form-control" name="{{ $n }}" value="1" @if(old($n, $d) == '1') checked @endif> | |
@if ($errors->has($n)) | |
<small class="text-danger">{{ $errors->first($n) }}</small> | |
@endif | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" action="{{ route("users.store") }}"> | |
@method("POST") | |
@csrf | |
@include('form.input', ['n' => 'name', 'l' => 'Name', 'r' => true, 'd' => 'Default Name']) | |
@include('form.input', ['n' => 'email', 'l' => 'Email', 'r' => true, 'a' => true, $t => 'email']) @include('form.submit', ['l' => 'Create Link']) | |
@include('form.submit', ['l' => 'Create new User']) | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
$t = $t ?? 'text'; // type of input | |
$d = $d ?? null; // default value | |
$p = $p ?? 'Enter ' . $l; // placeholder text | |
$r = $r ?? false; // is required or not | |
$a = $a ?? false; // is autofocused or not | |
@endphp | |
<div class="form-group row"> | |
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label> | |
<div class="col-md-8"> | |
<input id="{{ $n }}" type="{{ $t }}" class="form-control" name="{{ $n }}" value="{{ old($n, $d) }}" placeholder="{{ $p }}" @if($r) required @endif @if($a) autofocus @endif> | |
@if ($errors->has($n)) | |
<small class="text-danger">{{ $errors->first($n) }}</small> | |
@endif | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
$d = $d ?? null; // default value | |
$r = $r ?? false; // is required or not | |
$a = $a ?? false; // is autofocused or not | |
@endphp | |
<div class="form-group row"> | |
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label> | |
<div class="col-md-8"> | |
<select id="{{ $n }}" class="form-control" name="{{ $n }}" @if($r) required @endif @if($a) autofocus @endif> | |
<option value="">-- SELECT --</option> | |
@foreach($i as $item) | |
@if($item == old($n, $d)) | |
<option value="{{ $item }}" selected>{{ $item }}</option> | |
@else | |
<option value="{{ $item }}">{{ $item }}</option> | |
@endif | |
@endforeach | |
</select> | |
@if ($errors->has($n)) | |
<small class="text-danger">{{ $errors->first($n) }}</small> | |
@endif | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="form-group mx-auto mb-0"> | |
<button type="submit" class="btn btn-primary">{{ $l }}</button> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php | |
$d = $d ?? null; // default value | |
$p = $p ?? 'Enter ' . $l; // placeholder text | |
$r = $r ?? false; // is required or not | |
$a = $a ?? false; // is autofocused or not | |
@endphp | |
<div class="form-group row"> | |
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label> | |
<div class="col-md-8"> | |
<textarea id="{{ $n }}" class="form-control" name="{{ $n }}" placeholder="{{ $p }}" @if($r) required @endif @if($a) autofocus @endif>{{ old($n, $d) }}</textarea> | |
@if ($errors->has($n)) | |
<small class="text-danger">{{ $errors->first($n) }}</small> | |
@endif | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should release a package ;)