Search code examples
laravelckeditorlaravel-3laravel-blade

Using CKEditor inside blade template [Laravel 3.x]


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?


Solution

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