Answer the question
In order to leave comments, you need to log in
Calling unknown method: frontend\models\Post::addRule() does not add a validation rule, what is the reason?
Calling unknown method: frontend\models\Post::addRule() does not add a validation rule, what is the reason?
Why is the method not found?
use Yii;
use frontend\models\Post;
use yii\base\DynamicModel;
use yii\db\Query;
use yii\web\UploadedFile;
$maxSize = 2097152;
$extensions = 'jpeg, jpg, png, gif';
$model = new Post();
$post = Yii::$app->request->post();
$uploadParam = $post['field_model'];
$model->addRule($uploadParam, 'image', [
'maxSize' => $maxSize,
'extensions' => explode(', ', $extensions),
])->validate();
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