Answer the question
In order to leave comments, you need to log in
How do post data come in yii2?
Good afternoon!
How does the post data type fileInput come?
The form looks like this:
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= $form->field($model, 'firstname')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'job_position')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'photo')->fileInput(); ?>
<?= $form->field($model, 'text')->widget(CKEditor::className(),[
'editorOptions' => [
'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать
'inline' => false, //по умолчанию false
],
]); ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Создать' : 'Изменить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post())) {
echo '<pre>'; var_dump(Yii::$app->request->post());
Answer the question
In order to leave comments, you need to log in
Here it is: www.yiiframework.com/doc-2.0/guide-input-file-uplo...
Duck, I already read it, but why is there no value in the photo field in this array? I don’t catch up with something, in the model it is necessary to declare a variable public $ photo and why is it needed?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question