CActiveForm ajax submit not working

I’m new to Yii and trying to make registration form using CPortlet. I faced a problem that ajax validation is not triggered, because it does not pass this standart condition:

if(isset($_POST['ajax']) && $_POST['ajax'] == 'registration-form')

I’ve searched a lot, but couldn’t find any solution. Is that possible that pressing submit button in form doesn’t create POST ajax variable? enableAjaxValidation is set to ‘true’ in form.

1 Like

do you have ajax validation enabled on the form?

paste your form code

I am using this form as widget, so Controller (in my case - CPortlet) and it’s view are in ‘Components’ folder.

This is view

<?php $form1=$this->beginWidget('CActiveForm', array(



        'enableClientValidation' => true,

        'clientOptions' => array(

		'validateOnSubmit' => true,



<div class="row">

        <?php echo $form1->textField($form,'username'); ?>

	<?php echo $form1->error($form,'username');?>



<div class="row submit">

        <?php echo CHtml::submitButton(Yum::t('Registration')); ?>


<?php $this->endWidget(); ?>

and Controller

class RegistrationWidget extends CPortlet


        public function init()




	protected function renderContent()




		$form = new YumRegistrationForm;

		$profile = new YumProfile;


		if (isset($_POST['YumRegistrationForm'])&&isset($_POST['YumProfile'])) { 

		  $form->attributes = $_POST['YumRegistrationForm'];

		  $profile->attributes = $_POST['YumProfile'];

		  if(!$form->hasErrors() && !$profile->hasErrors()) {

			$user = new YumUser;

			$user->register($form->username, $form->password, $profile);

			$user->profile = $profile;




                  $this->render($this->view, array('form' => $form,'profile' => $profile));


        protected function performAjaxValidation($models) {

		if(isset($_POST['ajax']) && $_POST['ajax'] == 'registration-form') {

			echo CActiveForm::validate($models);