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
)); ?>
Thanks for helping me!.
You can use htmlOptions : <? php $form = ActiveForm::begin( [ 'action' => '/login', 'htmlOptions' => [ 'class' => 'userform' ] ] ); // ... add all your inputs here for example: echo $form->field($model, 'login'); ActiveForm::end(); ?>
ActiveForm is a widget that builds an interactive HTML form for one or multiple data models. For more details and usage information on ActiveForm, see the guide article on forms.
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',
)
)); ?>
from http://www.yiiframework.com/doc/api/1.1/CActiveForm#htmlOptions-detail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With