Answer the question
In order to leave comments, you need to log in
Why is $_GET passed instead of $_POST?
There is a form in the view file that is responsible for passing the model data entered in the field to adding it to the database:
<form>
<?php $form = ActiveForm::begin(['action' =>['site/editdata'], 'id' => 'form-editdata', 'method' => 'post',]); ?>
<div class="input-block">
<p>Фамилия и Имя Отчество*</p>
<p><?php echo Yii::$app->user->identity->fio;?></p><br>
<input type="text" name="EditdataForm[fio]" class="input__item">
</div>
<div class="input-block clearfix">
<div class="col-sm-6">
<div class="left-input">
<div class="row">
<p>Мобильный телефон*</p>
<p><?php echo Yii::$app->user->identity->phone;?></p><br>
<input type="text" name="EditdataForm[phone]" class="input__item">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="row">
<div class="right-input">
<div class="post-input">
<p>Электронная почта *</p>
<p><?php echo Yii::$app->user->identity->email;?></p><br>
<input type="text" name="EditdataForm[email]" class="input__item">
</div>
</div>
</div>
</div>
<div class="input-block">
<?= Html::submitButton('Сохранить', ['class' => 'save__btn', 'name' => 'editdata-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</form>
<?php $form = ActiveForm::begin(['id' => 'form-editdata']); ?>
<?= $form->field($model, 'fio')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'street') ?>
<?= $form->field($model, 'house') ?>
<?= $form->field($model, 'housing') ?>
<?= $form->field($model, 'apartment') ?>
<?= $form->field($model, 'phone') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group">
<?= Html::submitButton('Edit', ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?>
</div>
<?php ActiveForm::end(); ?>
public function editdata()
{
if (!$this->validate()) {
return null;
}
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->fio = $this->fio;
$user->apartment = $this->apartment;
$user->house = $this->house;
$user->housing = $this->housing;
$user->street = $this->street;
$user->phone = $this->phone;
$user->setPassword($this->password);
return $user->save() ? $user : null;
}
public function actionEditdata()
{
return $this->render('editdata');
}
ActiveForm::begin(['action' =>['site/editdata'], 'id' => 'form-editdata', 'method' => 'post',])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question