add css class to the form (Yii form builder) -
how can add css class or id form element has been created yii form bui imagine have created form follows:
controller:
public function actionregistration() { $form = new cform('application.views.user.registerform'); $form['user']->model = new users; $form['profile']->model = new profile; if(isset($_post['users'])) { $form['profile']->model->attributes = $_post['profile']; $_post['users']['mobile'] = $_post['profile']['mobile']; $form['user']->model->attributes = $_post['users']; if($form->validate()) { $user = $form['user']->model; $profile = $form['profile']->model; if($profile->save(false)) { $user->profile_id = $profile->id; $user->save(false); } } else { $errors = array_merge($form['profile']->model->errors, $form['user']->model->errors); } } $this->render('registration', array('form'=>$form)); }
view
<?php echo $form->renderbegin(); ?> <div class="row"> <div class="nine columns"> <div class="field"> <?php echo $form['profile']['fname']; ?> </div> <div class="field"> <?php echo $form['profile']['lname']; ?> </div> <div class="row"> <div class="eight columns"> <div class="field phone"> <?php echo $form['profile']['phone']; ?> </div> </div> <div class="eight columns"> <div class="field mobile"> <?php echo $form['profile']['mobile']; ?> </div> </div> </div> <div class="row"> <div class="eight columns"> <div class="field password"> <?php echo $form['user']['pass']; ?> </div> </div> </div> <div class="field address email"> <input type="text" name="users[email]" value="" placeholder="email" class="text input"> </div> </div> </div> <div class="row text-center margins"> <span class="medium warning btn"> <button type="submit"submit</button> </span> </div> <?php echo $form->renderend(); ?>
i want set id or class form element generated $form->renderbegin() function. don't know how add html options form. please me.
in view file before renderbegin make assignment attributes:
<?php $form->attributes= array('id'=>'el123', 'class'=>'qwe'); echo $form->renderbegin(); ?>
Comments
Post a Comment