Hi…
I used Gii for CRUD, the table is called "test" (PostgreSQL).
Form validation on Sumbit works fine, but fails with AJAX.
So, by this time I have the following:
in TestController:
...
public function actionCreate()
{
$model=new Test;
$this->performAjaxValidation($model); //I uncommented this string
...
}
...
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='test-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
in Model (Test):
public function rules()
{
return array(
array('firstname, surname', 'required','message'=>'Field required: {attribute}'),
...
in _form.php:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'test-form',
'enableAjaxValidation'=>true,
...
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
In /var/www/protected/views/layouts/mail.php (Ubuntu) I have the following string (and the required file is in the right place):
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.yiiactiveform.js"></script>
Also I tried earlier the example (available on www.dbhelp.ru/ajax-partialrender-update/page/), it worked as desired on freshly installed yii, but then it stopped working after I enabled Yii urlManager and Apache mod_rewrite module and then changed the content of /var/www/.htaccess as follows:
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
I really don’t know what and where I do wrong. May be I haven’t enabled needed js-files, or Apache configuration and file permissions in my Ubuntu block the access to php-scripts in ajax requests?
Thank you.