S
S
sawa42015-06-19 13:19:34
Yii
sawa4, 2015-06-19 13:19:34

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(); ?>

When changing the controller action like this:
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post())) {

            echo '<pre>'; var_dump(Yii::$app->request->post());

all fields are output except fileInput example

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2015-06-19
@Stalker_RED

Here it is: www.yiiframework.com/doc-2.0/guide-input-file-uplo...

S
sawa4, 2015-06-19
@sawa4

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?

A
Alexander, 2015-06-19
@Sassoft

Were you taught how to use a debugger?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question