Hi all, i have an issue where a custom validation rule worked before i set a scenario
array('customer_ID', 'justone'),
Where just one is a function that check that the user has chosen a customer from the dropdown or a checkbox to select all customers, however when i add a scenario
public function actionIndex() {
$this->layout = 'column1';
$this->pageTitle = "Create report for date range";
$model = new Reports;
$model->setScenario('daterange');
$this->performAjaxValidation($model);
if (isset($_POST['Reports'])) {
//create criteria and send to pdf
$model->attributes = $_POST['Reports'];
if ($model->validate()) {
//begin criteria
$criteria = new CDbCriteria;
//dropdown first
if (!empty($model->customer_ID)) {
$criteria->compare('customer_ID', $model->customer_ID);
$criteria->addBetweenCondition('job_logged_date', $model->dateFrom, $model->dateTo);
$custmodel = Customers::model()->findbyPK($model->customer_ID);
$totalTime = $custmodel->total_time;
$title = "Date Range Job Report For :" . $custmodel->company . " From : ".$model->dateFrom. " To : ". $model->dateTo."";
$subtitle = "Total time: " . $totalTime . " Contracted Time : " . CHtml::encode($custmodel->aloc_time) . "";
$this->createpdf($criteria, $model, $title, $subtitle , $custmodel );
}
else {
//all customers checkbox
$criteria->addBetweenCondition('job_logged_date', $model->dateFrom, $model->dateTo);
$custmodel = Customers::model()->findAll();
$title = "Date Range Job Report For : All customers in date range ";
$subtitle = "";
$this->createpdf($criteria, $model, $title, $subtitle, $custmodel);
}
}
}
$this->render('index', array(
'model' => $model,
));
}
That is the whole action , and yeah the validation isnt trigered, its almost like its passing validation, but i am submitting a form that has nothing selected . It seems weird to me because i have scenarios working in other parts of the app
Don’t know if this has any significance but it is a form model , nothing is saved to the database