N
N
Nikolai Novosad2016-05-29 21:01:54
Yii
Nikolai Novosad, 2016-05-29 21:01:54

Yii2 no file when loading image?

Hello.
Generated via CRUD forms. You need to upload images. In the database field 'VARCHAR'. advanced template.
In the 'Team' model I add:

use yii\base\models;
use yii\web\UploadedFile;
...........................................
[['photo_team'], 'file'],

In backend/views/team/_form.php
<?= $form->field($model, 'photo_team')->fileInput() ?>

But absolutely nothing happens. No error, no file selection field. I remove everything from backend/views/team/_form.php - the form is as it was - it is.
The view also has one more -
<?= $form->field($model, 'party')->dropDownList([ 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E', 'F' => 'F', ], ['prompt' => '']) ?>

but there is no list in frontend.
CRUD did this
What am I doing wrong?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Timofeev, 2016-05-29
@webinar

1. To develop on yii2, you need to enable the debug panel to see errors.
2. Most likely a problem with form validation.
3. Give the full codes, models, views with the form and the controller that processes it.
4.

I remove everything from backend/views/team/_form.php - the form is as it was - it is.
- whatoooo is that? Write more in Russian. What does "the form as it was - so it is" mean? Where there is? In the browser in code?
I'm cleaning everything
- What is this?

M
Max, 2016-05-29
@matios

If you clear the backend/views/team/_form.php file and there are no changes on the page, then you are working with the wrong file

A
Alexander Pantyukhov, 2016-05-30
@Paromon

Try using kartik widgets.
on my page like this:

echo \kartik\widgets\FileInput::widget([
    'name' => 'attachment',
    'pluginOptions' => [
        'showPreview' => false,
        'showCaption' => true,
        'showRemove' => true,
        'showUpload' => true,
        'uploadUrl' => \yii\helpers\Url::to(['/report/report-upload'])
    ]
]);

Everything works fine. Only then I had to increase the maximum size of the uploaded file, but it already seemed to be in the PHP settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question