Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii - CActiveForm - additional form attribute

I need to pass data-ajax = "false" property to the form. This property is needed for jQuery Mobile to make it stop loading pages with Ajax.

Here is my code:

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'login-form',
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
    ),  
    'focus'=>array($model,'username'),
    'data-ajax'=>false,
)); ?>

......

<?php $this->endWidget(); ?>
</div><!-- form -->

so my html output would look like this:

<form id="login-form" method="post" action="/*********" data-ajax ="false">

Unfortunately im getting a CException "Property "CActiveForm.data-ajax" is not defined." error. Am I missing something?

like image 607
Kalvin Klien Avatar asked Dec 20 '22 21:12

Kalvin Klien


1 Answers

solved this problem by adding

'htmlOptions' => array("data-ajax"=>"false")


<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'login-form',
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,       
    ),  
    'htmlOptions' => array("data-ajax"=>"false"),
    'focus'=>array($model,'username'),

)); ?>
like image 140
Kalvin Klien Avatar answered Jan 02 '23 17:01

Kalvin Klien