如何在Yii框架中向Form添加类? [英] How to add class to Form in Yii framework?
本文介绍了如何在Yii框架中向Form添加类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Yii中有一个表单,我想在该表单中添加一个类:
I have a form in Yii, and I want to add a class to the form :
<form class="subscribe_form" action="#" method="post">
我尝试了此操作,但没有用:
I tried this but it's not working :
<?php $form=$this->beginWidget('CActiveForm', array(
'class'=>'subscribe_form',
'id'=>'mail-list-addmail-form',
'enableAjaxValidation'=>false
)); ?>
感谢您的帮助!。
推荐答案
您需要传递htmlOptions属性,例如:
You need to pass an htmlOptions property, like this:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'mail-list-addmail-form',
'enableAjaxValidation'=>false,
'htmlOptions'=>array(
'class'=>'subscribe_form',
)
)); ?>
来自 http://www.yiiframework.com/doc/api/1.1/CActiveForm#htmlOptions-detail
这篇关于如何在Yii框架中向Form添加类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文