Answer the question
In order to leave comments, you need to log in
Why does Yii::$app->request->post() fail?
The action stopped working in the controller.
The logs are clean, no errors are thrown.
If ($form->load(Yii::$app->request->post()) && $form->validate()) doesn't work.
The request has a filled $_POST, but the Request Body is Empty.
In the create action, it returns a page with filled fields...
Action code:
public function actionCreate()
{
$form = new ProductCreateForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$product = $this->service->create($form);
return $this->redirect(['view', 'id' => $product->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
Answer the question
In order to leave comments, you need to log in
$form->load(Yii::$app->request->post());
if ($form->validate()) {
....
} else {
$errors = $form->errors;
print_r($errors);
}
By a happy coincidence, it turned out that the product did not want to be saved until there was not a single "Product characteristics" object in the system
Damn, I almost turned gray ...
I'll pick the Characteristics so as not to interfere.
Maybe it will be possible to understand why they spoiled life so much.
Many thanks to all who responded and + to karma
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question