Yii - CActiveForm - Optional Form Attribute

I need to pass property data-ajax = "false" to the form. This property is necessary for jQuery Mobile to stop loading pages using 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 will look like this:

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

Unfortunately, I get a CException "Property" CActiveForm.data-ajax "undefined". error. Did I miss something?

+4
source share
1 answer

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'), )); ?> 
+10
source

Source: https://habr.com/ru/post/1415666/


All Articles