Multiple Questions Concerning Ajax

Hello,

I am atm implementing some ajax stuff and I have some questions:

I have wrote my own validator to validate a date range:

[spoiler]


<?php

class DateRange extends CValidator {

    protected function validateAttribute($object, $date) {

        $User_ID = 'User_ID';

        $userID = $object->$User_ID;

        $checkDate = strtotime($object->$date);

        $models = Vacation::model()->findAll("User_ID='" . $userID . "'");

        foreach ($models as $model) {

            $modelStart = strtotime($model->getAttribute('startdate'));

            $modelEnd = strtotime($model->getAttribute('stopdate'));

            if($checkDate >= $modelStart && $checkDate <= $modelEnd) {

                $this->addError($object, $date, 'Das Datum befindet sich in einem Urlaub.');

                break;

            }

        }

    }

}

?>



[/spoiler]

If the date is incorrect an error is added (“Das Datum befindet sich in einem Urlaub.”).

I have added two fields to my view to display potential errors:




    <?php echo $form->error($model,'startdate'); ?>

    <?php echo $form->error($model,'stopdate'); ?>



But the errors never show up even though the rule clearly does it’s job.

Secondly:

I would like to update multiple divs with one ajaxSubmiButton but I didn’t find any way of doing this.

Is there maybe a plugin or do I have to create my own button and if so, how?

See here: http://www.yiiframework.com/doc/api/1.1/CHtml#ajax-detail

In your ajaxSubmitButton [font="Courier New"]options[/font], you may want to use the [font="Courier New"]success[/font] property instead of the [font="Courier New"]update[/font] one, and put jQuery code in order to update each div separately. I mean instead of:


'update' => 'SingleDivToUpdate'

You’d write:


'success' => "js: function(response) {

    $('#FirstDivToUpdate').html(response);

    $('#SecondDivToUpdate').html(response);

}"