您的位置:首页 > 编程语言 > PHP开发

yii_1_1_17_11(后台添加文章小物件创建radio和select-2016-2-12)

2016-02-12 00:00 731 查看
引入编辑器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');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: