joris

CKEditor

Apr 7th, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. File Layout ane registrasiin :
  2.  
  3. <?php
  4. $this->registerJsFile('/template/ckeditor/ckeditor.js', ['position' => \yii\web\View::POS_END]);
  5.  
  6. $CKEditor = "
  7.         if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
  8.                     CKEDITOR.tools.enableHtml5Elements( document );
  9.                     CKEDITOR.config.height = 150;
  10.                     CKEDITOR.config.width = 'auto';
  11.  
  12.                     var initSample = ( function() {
  13.                     var wysiwygareaAvailable = isWysiwygareaAvailable(),
  14.                     isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
  15.  
  16.                     return function() {
  17.                                 var editorElement = CKEDITOR.document.getById( 'editor' );
  18.  
  19.                                 if ( wysiwygareaAvailable ) {
  20.                                         CKEDITOR.replace( 'editor' );
  21.                                 } else {
  22.                                         editorElement.setAttribute( 'contenteditable', 'true' );
  23.                                         CKEDITOR.inline( 'editor' );
  24.                                 }
  25.                     };
  26.  
  27.  
  28.                     function isWysiwygareaAvailable() {
  29.                                 if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
  30.                                         return true;
  31.                                 }
  32.                                 return !!CKEDITOR.plugins.get( 'wysiwygarea' );
  33.                     }
  34.  
  35.                     })();
  36.                     initSample();
  37. ";
  38. $this->registerJS($CKEditor);
  39. ?>
  40.  
  41.  
  42. Lalu di view ane panggil :
  43.  
  44. <?= $form->field($model, 'description')->textArea(['autocomplete'=>'off', 'class'=>'form-control', 'id' => 'editor'])->label(false) ?>
Advertisement
Add Comment
Please, Sign In to add comment