Answer the question
In order to leave comments, you need to log in
Submit form doesn't work. Why?
Hello!
There is a form with different elements. When you click on the submit button - the page is reloaded and not submitted, i.e. I don't get into the $model->load condition at all. Why is that?
I open and close the form like this:
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?php ActiveForm::end(); ?>
$this->view->title = Yii::$app->params['applicationName'].' | '.Yii::t('app', 'Documents circulation');
$model = new Documents();
if($model->load(Yii::$app->request->post()) && $model->validate()) {
echo 'submitted!';
}
return $this->render('new', compact('model'));
Answer the question
In order to leave comments, you need to log in
This means that loading or validation does not work, the validator interferes somewhere and you do not show its field or its errors.
Try in the controller before rendering to see what's wrong with the model:
if($_POST) {
header('content-type: text/html; charset=utf-8');
echo '<pre>';
@print_r($model);
echo '</pre>';
exit(__FILE__ . ': ' . __LINE__);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question