Summernote不使用laravel形式

时间:2018-05-03 10:57:27

标签: laravel summernote

{!! Form::open(array('route' => 'posts.store', 'files' => true)) !!}
{{ Form::label('title', 'Title:') }}
{{ Form::text('title', null, array('class' => 'form-control'))}}

{{ Form::label('slug', 'Slug:') }}
{{ Form::text('slug', null, array('class' =>'form-control', 'required' =>
'', 'minlength' => '5', 'maxlength' => '255')) }}

{{ Form::label('category_id', 'Category:') }}
    <select class="form-control" name="category_id">
     @foreach($categories as $category)
       <option value='{{ $category->id }}'>{{ $category->name }}      
       </option>
     @endforeach
    </select>

{{ Form::label('tags', 'Tags:') }}
    <select class="form-control select2-multi" name="tags[]" multiple="multiple">
     @foreach($tags as $tag)
       <option value='{{ $tag->id }}'>{{ $tag->name }} </option>
     @endforeach
     </select>


{{ Form::label('body', 'Blog post:') }}                  
{{ Form::textarea('body', null, array('class' => 'form-control', 'id'=>'summernote', 'name'=>'editordata'))}}

{{ Form::submit('Create Post', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top: 20px'))}}
{!! Form::close() !!}

我遇到问题,当我向textarea写一些内容或添加带summernote的图片时,点击创建帖子我收到错误'正文字段是必需的'。我认为我的问题在于这一行:

{{ Form::label('body', 'Blog post:') }}                  
{{ Form::textarea('body', null, array('class' => 'form-control', 'id'=>'summernote', 'name'=>'editordata'))}}

有人有解决方案吗?

1 个答案:

答案 0 :(得分:0)

我认为问题在于您的数组

{{ Form::textarea('body', null, array('class' => 'form-control', 'id'=>'summernote', 'name'=>'editordata'))}}

您明确覆盖了html textarea的name属性。删除名称=&gt; ..或使用以下内容:

{{ Form::textarea('body', null, array('class' => 'form-control', 'id'=>'summernote', 'name'=>'body'))}}