Using CKEditor inside blade template [Laravel 3.x]

后端 未结 2 1985
悲哀的现实
悲哀的现实 2021-01-27 22:30

I\'d like to use this bundle: laravel-ckeditor but I have troubles in nesting it in my view (all previous installation steps I\'ve done successfully). How can i connect Form::te

相关标签:
2条回答
  • 2021-01-27 23:03

    here is an example of working TinyMCE:

    <!-- title field -->
        <p>{{ Form::label('title', 'Tytuł') }}</p>
        {{ $errors->first('title', '<div class="alert alert-error"><a class="close">×</a>:message</div>') }}
        <p>{{ Form::text('title', $value = $post->title, $attributes = array(Input::old('title'))); }}</p>
    <!-- body field -->
    <p>{{ Form::label('body', 'Tekst') }}</p>
            {{ $errors->first('body', '<div class="alert alert-error"><a class="close">×</a>:message</div>') }}
            <p>{{ RTE::rich_text_box('body',$post->body,array('att'=>array('id'=>'editorID'),'selector'=>'editorSelector','mode'=>'full','setup'=>array('skin'=>'o2k7','skin_variant'=>'black'))) }}
            </p>
        <!-- submit button -->
            <p>{{ Form::submit('Edit') }}</p>
    

    the trick was to use it INSTEAD of Form::text (and change all file permissions in /laravel/public/bundles/* for 0755) the same thing was about CKEditor. hope it will help others in a future (:

    0 讨论(0)
  • 2021-01-27 23:07

    steps are:

    1. install the editor first via composer by running the command:

      composer require unisharp/laravel-ckeditor

    2. Add this to ServiceProvider in config/app.php to the providers array: 'providers' => [

      Unisharp\Ckeditor\ServiceProvider::class,

    3. back at the command line again, Publish the resources:

      php artisan vendor:publish --tag=ckeditor

    4. Now to embed it into a textarea bind them with an id

    <script src="{{ url('/vendor/unisharp/laravel-ckeditor/ckeditor.js') }}"></script>
    <script>
        CKEDITOR.replace( 'your_id' );
    </script>
    
    <textarea id="your_id"></textarea>
    

    for these steps they had their own github repository



    NOTE: if you are using Laravel Collictive to add the textarea and bind the id to it use this:

    {{Form::textarea('desc', '', ['id' => 'your_id'])}}
    

    AND then display the nice formatted content like this:

    {!!$post->desc!!}
    

    where $post->desc is the returned stored value from the database

    0 讨论(0)
提交回复
热议问题