2013-02-01 52 views
0

Yii新手在这里, 我想知道是否还有渲染一个我以前在CKEditor TextArea中创建的视图。Yii:渲染CKEditor文本区域内的视图

我试着在值属性中渲染它,但不幸的是它没有工作。

有没有办法做到这一点?或者我应该创建一个单独的函数并将页面输出到文本区域?

任何提示,建议或指针非常感谢!谢谢

  <?php 
    $this->widget('application.extension.CKEditor.TheCKEditorWidget', array(
     'model' => $model, 
     'attribute' => 'body', 
     'value' => //rendered page,  
     'height' => '400px', 
     'width' => '800px', 
     'toolbarSet' => 'Full', 
     'ckeditor' => Yii::app()->basePath . '/../ckeditor/ckeditor.php', 
     'ckBasePath' => Yii::app()->baseUrl . '/ckeditor/', 
     'css' => Yii::app()->baseUrl . '/css/index.css', 
    )); ?> 
+0

看到这个帖子http://www.yiiframework.com/forum/index.php/topic/9341-ckeditor-widget-in-a-cactiveform/ –

回答

1

如果指定modelattribute属性value属性不被使用。所以为了在CKeditor中显示一些东西,你必须在渲染widget之前将它指定为$model->body="Your content goes here"。在你的情况下,你必须在CKEditor中渲染一个视图。因此使用带有第三个参数的CController::render()函数为true。即

<?php 
    $model->body=$this->render("viewName",array(),true); 

    $this->widget('application.extension.CKEditor.TheCKEditorWidget', array(
     'model' => $model, 
     'attribute' => 'body', 
     'height' => '400px', 
     'width' => '800px', 
     'toolbarSet' => 'Full', 
     'ckeditor' => Yii::app()->basePath . '/../ckeditor/ckeditor.php', 
     'ckBasePath' => Yii::app()->baseUrl . '/ckeditor/', 
     'css' => Yii::app()->baseUrl . '/css/index.css', 
    )); ?> 
+0

太谢谢你了! – KayKay