【发布时间】:2014-03-12 11:01:57
【问题描述】:
尝试将 CKEditor 与 Yii 框架一起用于我的文本区域
我收到此错误
TheCKEditorWidget 找不到视图“TheCKEditorWidget
这是我的观点_form.php
$this->widget('application.extensions.TheCKEditor.TheCKEditorWidget',array(
'model'=>$model, # Data-Model (form model)
'attribute'=>'field', # Attribute in the Data-Model
'height'=>'400px',
'width'=>'100%',
'toolbarSet'=>'Basic', # EXISTING(!) Toolbar (see: ckeditor.js)
'ckeditor'=>Yii::app()->basePath.'/../ckeditor/ckeditor.php',
# Path to ckeditor.php
'ckBasePath'=>Yii::app()->baseUrl.'/ckeditor/',
# Relative Path to the Editor (from Web-Root)
'css' => Yii::app()->baseUrl.'/css/index.css',
# Additional Parameters
) );
以及它们的用途,以下 ckeditor ,basepath
'ckeditor'=>Yii::app()->basePath.'/../ckeditor/ckeditor.php', # Path to ckeditor.php
'ckBasePath'=>Yii::app()->baseUrl.'/ckeditor/', # Relative Path to the Editor (from Web-Root)
'css' => Yii::app()->baseUrl.'/css/index.css', # Additional Parameters
下面是扩展类
protected\extensions\TheCKEditor\TheCKEditorWidget.php
class TheCKEditorWidget extends CInputWidget
{
public $ckeditor;
public $ckBasePath;
public $height = '375px';
public $width = '100%';
public $toolbarSet;
public $config;
public $css;
public function run()
{
if (!isset($this->ckeditor)){
throw new CHttpException(500,'Parameter "ckeditor" has to be set!');
}
if (!isset($this->ckBasePath)){
throw new CHttpException(500,'Parameter "ckBasePath" has to be set!');
}
if (!$this->hasModel() && !isset($this->name)) {
throw new CHttpException(500,'Parameters "model" and "attribute" or "name" have to be set!');
}
if (!isset($this->toolbarSet)){
$this->toolbarSet = "Default";
}
$this->render('TheCKEditorWidget',array(
'ckeditor'=>$this->ckeditor,
'ckBasePath'=>$this->ckBasePath,
'model'=>$this->model,
'attribute'=>$this->attribute,
'name'=>$this->name,
'value'=>$this->value,
'height'=>$this->height,
'width'=>$this->width,
'toolbarSet'=>$this->toolbarSet,
'config'=>$this->config,
'css'=>$this->css,
));
}
}
当我运行该特定视图 _form 被调用时,我收到此错误
**TheCKEditorWidget 找不到视图“TheCKEditorWidget
有人能解释一下原因和解决方案吗?
【问题讨论】:
标签: php yii ckeditor yii-extensions