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

I am using Laravel 5.2 and using UniSharplaravel-ckeditor package to implement ckeditor in my project.

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();
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745135934a4613197.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信