本文整理汇总了PHP中app\models\Invoice::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::validate方法的具体用法?PHP Invoice::validate怎么用?PHP Invoice::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Invoice
的用法示例。
在下文中一共展示了Invoice::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Registration model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$registration_model = new Registration();
$registration_model->registration_type_id = 1;
$invoice_model = new Invoice();
if ($registration_model->load(Yii::$app->request->post())) {
$registration_model->file_payment_receipt = UploadedFile::getInstance($registration_model, 'file_payment_receipt');
switch ($registration_model->registration_type_id) {
case 2:
case 4:
case 5:
$registration_model->file_student_id = UploadedFile::getInstance($registration_model, 'file_student_id');
break;
}
$isValid = $registration_model->validate();
if ($registration_model->requires_invoice) {
if ($invoice_model->load(Yii::$app->request->post())) {
$isValid = $isValid && $invoice_model->validate();
var_dump($invoice_model->errors);
}
}
var_dump($registration_model->errors);
if ($isValid) {
if ($registration_model->save(false)) {
if ($registration_model->requires_invoice) {
$invoice_model->registration_id = $registration_model->id;
if ($invoice_model->save(false)) {
return $this->redirect(['view', 'id' => $registration_model->id]);
}
} else {
return $this->redirect(['view', 'id' => $registration_model->id]);
}
}
}
} else {
return $this->render('create', ['registration_model' => $registration_model, 'invoice_model' => $invoice_model]);
}
}