deltascience
deltascience

Reputation: 3380

How to add class to Form in Yii framework?

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!.

Upvotes: 6

Views: 10726

Answers (2)

msoa
msoa

Reputation: 1349

htmlOptions: additional HTML attributes that should be rendered for the form tag.

htmlOptions: there is commonly through all HTML helpers CHtml, CActiveForm and you can set the custom HTML options in this property.

Upvotes: 0

flyingjamus
flyingjamus

Reputation: 4023

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

Upvotes: 7

Related Questions