public function actionCreate($type) { $incoming = new Incoming(); $contact = new Contact(); if ($incoming->load(Yii::$app->request->post()) && $contact->load(Yii::$app->request->post())) { $contact->type = Contact::PERSON; $isValid = $incoming->validate(); $isValid = $contact->validate() && $isValid; if ($isValid) { $incoming->save(false); $contact->save(false); $from = new Endpoint(); $from->type = Endpoint::FROM; $from->doc_id = $incoming->id; $from->contact_id = $contact->id; $from->save(false); return $this->redirect(['index']); } else { Yii::trace($contact->errors); } } $incoming->type = Incoming::PERSON; $incoming->docdate = date('Y-m-d'); return $this->render('create', ['incoming' => $incoming, 'contact' => $contact]); }