J
J
Jony13372017-02-09 13:22:23
Yii
Jony1337, 2017-02-09 13:22:23

Unknown Property - yii\base\UnknownPropertyException?

Hello, there is such a minicode

<?
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<? if ($name) {?><h1>Ati introdus <b><?=$name;?></b> and <b><?=$email;?></b></h1> <? }?>
<? $f = ActiveForm::begin(['options'=>['enctype' => 'multipart/form-data']]);?>
<?=$f->field($form,'name')?>
<?=$f->field($form,'email')?>
<?= $f->field($form, 'imageFile')->fileInput() ?>
<?=Html::submitButton('Send');?>

<? ActiveForm::end();?>

swears at the line
<?=$f->field($form,'file') -> fileInput()?>
Unknown Property - yii\base\UnknownPropertyException
Getting unknown property: app\models\MyForm::file
What's the problem?
Up.
Here is the model
<?
namespace app\models;

use Yii;
use yii\base\Model;

class MyForm extends Model {
  
  public $name;
    public $email;
  public function rules () {
    return [
    [ ['name','email'],'required'],
    ['email','email','message'=>'Email gresit'],
 [['imageFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg']
    ];
  }
}
?>

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Fedorov, 2017-02-09
@qonand

it is written in the app\models\MyForm class there is no file attribute ...

I
Ilya, 2017-02-09
@rpsv

The class app\models\MyFormdoes not have a property named file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question