お知らせ登録・編集のバリデーションエラー表示

This commit is contained in:
shibafu 2019-03-16 12:29:33 +09:00
parent a998d7132f
commit 1fd43b5e38
3 changed files with 22 additions and 4 deletions

View File

@ -119,6 +119,8 @@ return [
'attributes' => [ 'attributes' => [
'email' => 'メールアドレス', 'email' => 'メールアドレス',
'password' => 'パスワード', 'password' => 'パスワード',
'title' => 'タイトル',
'content' => '本文',
], ],
]; ];

View File

@ -28,14 +28,22 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="title">タイトル</label> <label for="title">タイトル</label>
<input id="title" name="title" type="text" class="form-control" value="{{ old('title') }}"> <input id="title" name="title" type="text" class="form-control {{ $errors->has('title') ? ' is-invalid' : '' }}" value="{{ old('title') }}">
@if ($errors->has('title'))
<div class="invalid-feedback">{{ $errors->first('title') }}</div>
@endif
</div> </div>
<div class="form-group mt-3"> <div class="form-group mt-3">
<label for="content">本文</label> <label for="content">本文</label>
<textarea id="content" name="content" rows="15" class="form-control" maxlength="10000">{{ old('content') }}</textarea> <textarea id="content" name="content" rows="15" class="form-control {{ $errors->has('content') ? ' is-invalid' : '' }}" maxlength="10000">{{ old('content') }}</textarea>
<small class="form-text text-muted"> <small class="form-text text-muted">
最大 10000 文字、Markdown 形式 最大 10000 文字、Markdown 形式
</small> </small>
@if ($errors->has('content'))
<div class="invalid-feedback">{{ $errors->first('content') }}</div>
@endif
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">

View File

@ -29,14 +29,22 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="title">タイトル</label> <label for="title">タイトル</label>
<input id="title" name="title" type="text" class="form-control" value="{{ old('title') ?? $info->title }}"> <input id="title" name="title" type="text" class="form-control {{ $errors->has('title') ? ' is-invalid' : '' }}" value="{{ old('title') ?? $info->title }}">
@if ($errors->has('title'))
<div class="invalid-feedback">{{ $errors->first('title') }}</div>
@endif
</div> </div>
<div class="form-group mt-3"> <div class="form-group mt-3">
<label for="content">本文</label> <label for="content">本文</label>
<textarea id="content" name="content" rows="15" class="form-control" maxlength="10000">{{ old('content') ?? $info->content }}</textarea> <textarea id="content" name="content" rows="15" class="form-control {{ $errors->has('content') ? ' is-invalid' : '' }}" maxlength="10000">{{ old('content') ?? $info->content }}</textarea>
<small class="form-text text-muted"> <small class="form-text text-muted">
最大 10000 文字、Markdown 形式 最大 10000 文字、Markdown 形式
</small> </small>
@if ($errors->has('content'))
<div class="invalid-feedback">{{ $errors->first('content') }}</div>
@endif
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">