PHP Classes

Yii2 Form PreFiller: Fill form inputs with the values entered by a user

Recommend this page to a friend!
  Info   View files Documentation   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-10 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 17 This week: 1All time: 10,769 This week: 491Up
Version License PHP version Categories
yii2-form-prefiller 1.0MIT/X Consortium ...5PHP 5, User Management
Description Author

This package can fill form inputs with the values entered by a user.

It provides a component for applications that use the Yii framework to store input values for each application.

The next time the user fills the form with the same inputs, this package can retrieve the values that the user entered so the application can supply the information with the last importance.

Innovation Award
PHP Programming Innovation award nominee
October 2022
Number 7
Many Web site users do not have much patience to do repetitive tasks.

If they have to fill out lengthy forms with information, they may avoid it and not fill it, especially if the form asks for values already requested.

This package provides some help to minimize that issue. It provides a solution to "remember" the values that a user filled in a form with the same types of inputs.

So next time a Web site asks the user to fill a form with the same fields, this package can provide the values the user entered last time so that the application can pre-fill the inputs with those values.

Manuel Lemos
Picture of Insolita
  Performance   Level  
Name: Insolita <contact>
Classes: 15 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 9x

Details

Form assistant

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

Status

Installation

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.

Usage

Once the extension is installed, configure component :

'components'=>[
    '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([
       'skipFromStorageAttributes'=>['someAttr'],
       'validateStorage'=>false
  ]));

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([
       'method'=>'get',
       'defaults'=>['sort'=>'price','sortOrder'=>'desc','viewMode'=>'grid']
       'skipFromRequestAttributes'=>['searchQuery'],
       'validateRequest'=>true
  ]));

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files, 2 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagecontracts (3 files)
Files folder imagestorages (6 files)
  Plain text file BasePrefiller.php Class Class source
  Plain text file FormPrefiller.php Class Class source
  Plain text file PrefillConfig.php Class Class source

  Files folder image Files  /  src  /  contracts  
File Role Description
  Plain text file IFormPrefiller.php Class Class source
  Plain text file IMemorableForm.php Class Class source
  Plain text file IPrefillStorage.php Class Class source

  Files folder image Files  /  src  /  storages  
File Role Description
  Plain text file BaseStorage.php Class Class source
  Plain text file CookieStorage.php Class Class source
  Plain text file DbStorage.php Class Class source
  Plain text file RedisHashStorage.php Class Class source
  Plain text file RedisStorage.php Class Class source
  Plain text file SessionStorage.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageconfig (2 files)
Files folder imageunit (3 files)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file bootstrap.php Example Example script
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file yii Example Example script

  Files folder image Files  /  tests  /  config  
File Role Description
  Plain text file base.php Class Class source
  Plain text file console.php Class Class source

  Files folder image Files  /  tests  /  unit  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file DummyModel.php Class Class source
  Plain text file FormPrefillerTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:17
This week:1
All time:10,769
This week:491Up