最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Laravel ckeditor data doesn't insert in database - Stack Overflow

programmeradmin0浏览0评论

I am using Laravel 5.2 and using UniSharp/laravel-ckeditor package to implement ckeditor in my project.Everything seems to work fine.But when I send data of ckeditor input field,it's not inserting in database.The data of other input field working fine.When i use normal text-area instead of ckeditor it's also working fine.

The Form In my view:

 {{Form::open(array('url'=>'gettopics'))}}
            <input type="text" name="title" class="form-control"/>
           **<input type="textarea" name="detail" id="article-ckeditor">**
    {{Form::close()}}



<script>
        CKEDITOR.replace( 'article-ckeditor' );

    </script>

The Route:

Route::post('gettopics','TopicsController@gettopics');

The Controller:

public function gettopics(Request $request){
    $topic=new Topic;
$topic->title=$request->Input('title');
$topic->detail=$request->Input('detail');
 $topic->save();
}

I am using Laravel 5.2 and using UniSharp/laravel-ckeditor package to implement ckeditor in my project.Everything seems to work fine.But when I send data of ckeditor input field,it's not inserting in database.The data of other input field working fine.When i use normal text-area instead of ckeditor it's also working fine.

The Form In my view:

 {{Form::open(array('url'=>'gettopics'))}}
            <input type="text" name="title" class="form-control"/>
           **<input type="textarea" name="detail" id="article-ckeditor">**
    {{Form::close()}}



<script>
        CKEDITOR.replace( 'article-ckeditor' );

    </script>

The Route:

Route::post('gettopics','TopicsController@gettopics');

The Controller:

public function gettopics(Request $request){
    $topic=new Topic;
$topic->title=$request->Input('title');
$topic->detail=$request->Input('detail');
 $topic->save();
}
Share Improve this question asked Aug 20, 2016 at 10:32 Asm ArmanAsm Arman 3798 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

To render the html content, do this

{{!! $topic->detail !!}}

Note that if spaced wrongly, it will not work. So, make sure there is no space before the first '!!' and no space after the last '!!'.

Textarea as HTML tag is inserted incorrectly. You should change your code as follows:

My Editor:<br>
            <textarea name="article-ckeditor" id="article-ckeditor">&lt;p&gt;Initial editor content.&lt;/p&gt;</textarea>
            <script>
                CKEDITOR.replace( 'article-ckeditor' );
            </script>

Also in your controller, there is no function called Input, it's input. Change your controller as follows:

public function gettopics(Request $request){
    $topic=new Topic;
    $topic->title=$request->input('title');
    $topic->detail=$request->input('detail');
    $topic->save();
}
发布评论

评论列表(0)

  1. 暂无评论