S
S
Sergey2015-03-20 00:08:43
Yii
Sergey, 2015-03-20 00:08:43

Bad Request (#400) Unable to verify your data submission. in yii2 how to solve?

Gentlemen, I have an error when submitting a form in yii2:

Bad Request (#400) Unable to verify your data submission.

I have <?= Html::csrfMetaTags() ?> in my template code. I create a form using ActiveForm
Here is the form code:
<?
                 $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([
                                'model' => $model2,
                            'attribute' => 'date_from',
                            'value'  => $value,
                            'dateFormat' => 'dd.MM.yyyy',
                        ]);
                        echo '<span>End date of your education:</span>';
                        echo DatePicker::widget([
                                'model' => $model2,
                                'attribute' => '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']);
                        
                        } ?>

Initially, I thought that the problem was in the datepicker, but without it, everything is also ok. What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-03-23
@butteff

The problem I had was that in the view file it turned out that one form was inside another, which apparently caused problems with reading the token.

Y
Yago, 2015-03-22
@Yago

Why does Bad Request (#400) occur on a form in yii 2.0?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question