PHP Classes


Recommend this page to a friend!
  Classes of Insolita   Yii2 Form PreFiller   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Yii2 Form PreFiller
Fill form inputs with the values entered by a user
Author: By
Last change:
Date: 5 months ago
Size: 1,771 bytes


Class file image Download

Form assistant

Remember user-filled form data, prefill forms with remembered data Usefully for remember filter/sorting preferences, or make some sticky attributes



The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist insolita/yii2-form-prefiller "~1.0"

or add

"insolita/yii2-form-prefiller": "~0.0.1"

to the require section of your composer.json file.


Once the extension is installed, configure component :

    'prefiller' => [
            'class'   => \insolita\prefiller\FormPrefiller::class,
            'storage' => [
            //one of storage types - db,session,cookie,redis supported
                'class'    => \insolita\prefiller\storages\CookieStorage::class,

Support ActiveRecord models,yii\base\Model,DummyModel

Remember $model data in storage

   Yii::$app->prefiller->persist($model, new PrefillConfig([]));

Fill $model from storage

  Yii::$app->prefiller->fillFromStorage($model, new PrefillConfig([

Fill model from request->fillFromStorage->fillDefaults->persist if request update model

  $filter = new DummyModel(['page','sort','sortOrder','searchQuery','viewMode']);

  Yii::$app->prefiller->fill($filter, new PrefillConfig([