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?