I have got this error, when submit the form:
Bad Request (#400) Unable to verify your data submission.
I have got <?= Html::csrfMetaTags() ?>
in the layout. I think, that this problems I have, because I use datepicker. Form create with ActiveForm.
What I must to do? Here is code of the form:
<?
$form2 = ActiveForm::begin(['id' => 'user-univer']);
echo $form2->field($model2, 'university')->label('Input university name:');
echo $form2->field($model2, 'degree')->label('Input your education specialization:');
//echo $form2->field($model2, 'date')->label('Input your education date:');
echo '<label class="control-label">Education time:</label><br/>';
echo '<span>Start date of your education:</span>';
echo DatePicker::widget([
'name' => 'date_from',
'value' => $value,
'dateFormat' => 'dd.MM.yyyy',
]);
echo '<span>End date of your education:</span>';
echo DatePicker::widget([
'name' => 'date_to',
'value' => $value,
'dateFormat' => 'dd.MM.yyyy',
]);
echo '<br/><br/>';
echo $form2->field($model2, 'info')->textarea()->label('Any other information about your university degree:');
echo Html::submitButton('Add university', ['class' => 'btn btn-primary btn-univer']);
ActiveForm::end(['id' => 'user-univer']);
} ?>
UPD: without datepicker I have got the same problems, why? how to solve it?
I found that is missing a
/
in the end of input, ex:Working input is:
In my case I modified
yiisoft/yii2/helpers/BaseHtml
:problem may be due to csrf validation. Have you tried disabling csrf Validation
inside action try this
check this link
Add csrf token field in your form
Will solve your problem.