Skip to content

Commit

Permalink
use spatie/html for forms
Browse files Browse the repository at this point in the history
  • Loading branch information
fey committed Mar 13, 2024
1 parent 112c817 commit 21d50b0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
32 changes: 25 additions & 7 deletions resources/views/components/comment/_comment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,31 @@ class="btn btn-sm btn-link text-uppercase p-0 mr-2">
@endcan
</div>
@can('update', $comment)
@include('components.comment._modal', [
'modalTitle' => 'comment.edit_comment',
'comment' => $comment,
'method' => 'PUT',
'content' => $comment->content,
'submitLabel' => 'comment.update',
])
<div class="modal fade" id="comment-modal-{{ $comment->id }}" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
{{ html()->modelForm($comment, 'PUT', route('comments.update', ['comment' => $comment]))->open() }}
<div class="modal-header">
<h5 class="modal-title">{{ __('comment.edit_comment') }}/h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
{{ html()->hidden('commentable_type') }}
{{ html()->hidden('commentable_id') }}
<div class="form-floating">
{{ html()->textarea('content')->class('form-control h-100')->required() }}
<label for="content">{{ __('comment.enter_your_message') }}</label>
</div>
</div>
<div class="modal-footer text-left">
{{ html()->submit((__('comment.update')))->class('btn btn-success btn-sm text-uppercase') }}
{{ html()->button(__('comment.cancel'))->type('button')->class('btn btn-secondary btn-sm text-uppercase
mr-auto')->data('bs-dismiss', 'modal') }}
</div>
{{ html()->closeModelForm() }}
</div>
</div>
</div>
@endcan
@can('reply', $comment)
@include('components.comment.reply._modal')
Expand Down
32 changes: 0 additions & 32 deletions resources/views/components/comment/_modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,3 @@
* @var string $method
*/
@endphp
<div class="modal fade" id="comment-modal-{{ $comment->id }}" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
{{ BsForm::open(route('comments.update', ['comment' => $comment]), ['method' => $method]) }}
<div class="modal-header">
<h5 class="modal-title">{{ __($modalTitle) }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
{{ Form::hidden('commentable_type', $comment->commentable_type) }}
{{ Form::hidden('commentable_id', $comment->commentable_id) }}
{{ BsForm::textarea('content', $comment->content)->label(__('comment.update_comment_here'))->required()->attribute('rows', 3) }}
</div>
<div class="modal-footer text-left">
<a class="Link--muted position-relative d-inline"
href="https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax"
target="_blank" data-ga-click="Markdown Toolbar, click, help" id="dd_fc-new_comment_field_md_link"
aria-labelledby="tooltip-1668341388600-6483">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16"
data-view-component="true" class="octicon octicon-markdown v-align-bottom">
<path fill-rule="evenodd"
d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z">
</path>
</svg>
</a>
{{ BsForm::submit(__($submitLabel))->attribute('class', 'btn btn-success btn-sm text-uppercase') }}
{{ Form::button(__('comment.cancel'), ['class' => 'btn btn-secondary btn-sm text-uppercase mr-auto', 'data-bs-dismiss' => 'modal']) }}
</div>
{{ BsForm::close() }}
</div>
</div>
</div>

0 comments on commit 21d50b0

Please sign in to comment.