Last active
December 25, 2019 14:46
-
-
Save hoofdletterj/8447df35767cf961b702d0af9f22fc76 to your computer and use it in GitHub Desktop.
Blade form elements for sharing on create and edit forms
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
@foreach ($tags as $tag) | |
<input | |
type="checkbox" | |
name="tag[]" | |
value="{{$tag->id}}" | |
{{ | |
empty(old()) | |
? (in_array($tag->id, $userTagIDs) ? 'checked' : '') | |
: (is_array(old('tag')) && in_array($tag->id, old('tag')) ? 'checked' : '') | |
}} | |
> | |
<label for="tag[]">{{$tag->name}}</label> | |
@endforeach |
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
<input type="hidden" name="is_admin" value="0"> | |
<input type="checkbox" name="is_admin" value="1" | |
@if ($errors->any()) | |
{{ empty(old('is_admin')) ? '' : 'checked' }} | |
@else | |
{{ (($user->is_admin ?? false) == false ? '' : 'checked') }} | |
@endif | |
> |
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
<select name="status_id"> | |
<option disabled value="" {{(old('status_id', $user->status_id ?? null)) == null ? 'selected' : ''}}></option> | |
@foreach ($userStatuses as $status) | |
<option value="{{$status->id}}" {{(old('status_id', $user->status_id ?? null)) == $status->id ? 'selected' : ''}}> | |
{{$status->display_name}} | |
</option> | |
@endforeach | |
</select> |
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
<select name="gender"> | |
<option value="" {{ (old('gender', $user->gender ?? null) ) === null ? 'selected' : ''}}></option> | |
<option value="m" {{ (old('gender', $user->gender ?? null) ) == 'm' ? 'selected' : '' }}>Male</option> | |
<option value="f" {{ (old('gender', $user->gender ?? null) ) == 'f' ? 'selected' : '' }}>Female</option> | |
<option value="o" {{ (old('gender', $user->gender ?? null) ) == 'o' ? 'selected' : ''}}>Non-binary</option> | |
</select> |
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
<textarea name="notes" rows="8">{{ old('notes', $user->notes ?? null ) }}</textarea> |
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
<input type="text" name="first_name" value="{{ old('first_name', $tuseralent->first_name ?? null ) }}"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment