2019独角兽企业重金招聘Python工程师标准>>>
引入编辑器Ueditor
1.将ueditor文件夹放入项目的assets的org扩展文件夹下
2.调用的两个js为ueditor.all.min.js和ueditor.config.js
3.在模板页面中引入这个两个js
4.配置js
<script>
window.UEDITOR_HOME_URL = "<?php echo Yii::app()->request->baseUrl ?>/assets/admin/org/ueditor";//ueditor地址
window.onload = function(){
window.UEDITOR_CONFIG.initialFrameWidth = 900;
window.UEDITOR_CONFIG.initialFrameHeight = 600;//设置编辑器的宽高
UE.getEditor(textarea的id);
}
</script>
如果有上传图片的表单如何创建
<?php $form = $this->beginWidget('CActive',array(
'htmlOptions'=>array('enctype'=>'multipart/form-data')));
<?php $this->endWidget() ?>
radio按钮
<?php echo $form->radioButtonList(
$articleModel,
'type',
array(0=>'普通',1=>'热门'),
array('separator'=>'$nbsp'),//分隔符为空格
)
?>
select下拉列表
在控制器中:
$category = Category::model();//实例化
$categoryInfo - $category->findAllBySql("SELECT cid,cname FROM category");
$cateArr = array();
$cateArr[] = '请选择';
foreach($categoryInfo as $v){
$cateArr[$v->cid] = $v->cname;
}
<?php echo $form->dropDownList(
$categ,
'cid',
$cateArr,
)
?>
文件
<?php echo $form->fileField($articleModel,'thumb'); ?> //缩略图
文本区域:
<?php echo $form->textArea($articleModel,'info',array('cols'=>50,'rows'=>10,'maxlength'=>100)); ?>
不需要过滤的字段在rules中加上才能存入数据库.
array('content,info等等','safe');