質問

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::text() with this bundle?

When I add

<?php 
        $ckeditor = new CKEditor();
        $config = array();
        $config['toolbar'] = array(
            array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
            array( 'Image', 'Link', 'Unlink', 'Anchor' )
        );
        $events['instanceReady'] = 'function (ev) {
            alert("Loaded: " + ev.editor.name);
        }';
        $ckeditor->editor("field1", "
        Initial value.

        ", $config, $events);
    ?>

it simply creates new text area but unfortunately without any richtext functionality... Does anyone has already met this problem?

役に立ちましたか?

解決

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 (:

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top