2017 © Pedro Peláez
 

yii2-extension yii2-lookup

Yii2 lookup module

image

zacksleo/yii2-lookup

Yii2 lookup module

  • Wednesday, November 15, 2017
  • by zacksleo
  • Repository
  • 1 Watchers
  • 3 Stars
  • 5,248 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 10 % Grown

The README.md

Lookup Module For Yii2

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Climate Code Coverage StyleCI, (*1)

Migrate database

To add a lookup table to your database, following is the sql for lookup:, (*2)


CREATE TABLE IF NOT EXISTS `lookup` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(100) DEFAULT NULL, `name` varchar(100) DEFAULT NULL, `code` int(11) DEFAULT '1', `comment` text, `active` tinyint(1) DEFAULT '1', `order` int(11) DEFAULT '1', `created_at` int(11) DEFAULT NULL, `updated_at` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CK_Type_Name_Unique` (`type`,`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Or else you can use yii migration, (*3)


yii migrate/up --migrationPath=@zacksleo/yii2/lookup/migrations

Config the components

To access the lookup functionality anywhere in you application (either frontend or backend) follow the following steps:, (*4)

In your main.php under config folder add the following:
    'components' => [
        ---
        'lookup' => [
            'class' => 'zacksleo\yii2\lookup\models\Lookup',
        ],
        ---
    ]

Customize the form

Following are the few usage of lookup functionality:, (*5)


/*** dropdown list from lookup ***/ = $form->field($model, 'active')->dropDownList( Yii::$app->lookup->items('yes_no'), //['1'=>'Active', '2' => 'Pending'], ['prompt'=>'--- Select ---'] ) ?> /*** RadioButton List ***/ = $form->field($model, 'gender')->radioList( Yii::$app->lookup->items('male_female'), ['separator' => ''] ) ?> /*** CheckBoxes List ***/ = $form->field($model, 'language')->checkboxList( Yii::$app->lookup->items('language'), ['separator' => ''] ) ?> /*** Dropdown List from Lookup ***/ = $form->field($model, 'language')->dropDownList( Yii::$app->lookup->items('language'), ['prompt' => '--- Select ---'] ) ?>

Inspired By Ibrar Turi @ibrarturi, Thanks for his work., (*6)

The Versions

15/11 2017

dev-master

9999999-dev

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 module lookup

15/11 2017

1.2.1

1.2.1.0

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 module lookup

07/08 2017

1.2.0

1.2.0.0

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 module lookup

04/08 2017

dev-add-license-1

dev-add-license-1

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 module lookup

25/07 2017

1.1.2

1.1.2.0

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 module lookup

12/02 2017

1.1.0

1.1.0.0

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

yii2 module lookup

30/11 2016

1.0.0

1.0.0.0

Yii2 lookup module

  Sources   Download

BSD-3-Clause

The Requires

 

yii2 module lookup