2

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

2 Answers 2

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 '!!'.

Sign up to request clarification or add additional context in comments.

Comments

2

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

4 Comments

Now It's working.Thank You!!!.But How can i show the data in my page.Normal Procedure isn't working.
what do you mean by normal procedure? {{ $topic->detail }}?
Yeah.When I use {{ $topic->detail }},it's acting weird. <blockquote> <p><big>I told the family I needed time off to think for myself. The view is great up here, but I've seen it so many times after a while you get used to it. After a while the extraordinary loses its 'extra'.</big></p> </blockquote>
Sure, you need to escape it. Use {!! $topic->detail !!}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.