这是我的更新表单,但我将其用作部分,我想将当前图像嵌入到文件字段中,该字段名为" thumbnail"。如果没有为文件字段选择新图像,任何人都可以告诉我如何拍摄当前图像。以及如何从数据库值中包含日期?
{!! Form::model($article, ['method' => 'PATCH', 'files' => true, 'action' =>['ArticlesController@update', $article->id]]) !!}
<!-- Form thumbnail Input -->
<div class="form-group">
{!! Form::label('thumbnail', 'Thumbnail:', ['class' => 'control-label']) !!}
@if($article->thumbnail)
<div class="col-xs-2 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="/images/tn-{{$article->thumbnail}}"
alt="{{$article->titlel}}">
</a>
</div>
@endif
{!! Form::file('thumbnail', null, ['class' => 'form-control file']) !!}
</div>
<br>
<!-- Form body Input -->
<div class="form-group">
{!! Form::label('body', 'Body:', ['class' => 'control-label']) !!}
{!! Form::textarea('body', null, ['class' => 'form-control']) !!}
</div>
<!-- Form published_at Input -->
<div class="form-group">
{!! Form::label('published_at', 'Published:', ['class' => 'control-label']) !!}
{!! Form::input('date', 'published_at', date('Y-m-d'), ['class' => 'form-control']) !!}
</div>
<!-- Form Update Article Input -->
<div class="form-group">
{!! Form::submit($submitButtonText, ['class' => 'form-control btn btn-info pull-right']) !!}
</div>
{!! Form::close() !!}
答案 0 :(得分:0)
关于问题的日期部分
{!! Form::input('date', 'published_at', $article->published_at, ['class' => 'form-control']) !!}
PS:如果没有其他逻辑,我建议使用默认的created_at字段而不是published_at。