PHP Classes


Recommend this page to a friend!
  Classes of Uldis Nelsons   D3 Labels   Download  
Role: Documentation
Content type: text/markdown
Description: Read me
Class: D3 Labels
Attach label tag values to model objects
Author: By
Last change:
Date: 4 years ago
Size: 1,661 bytes


Class file image Download


Assign multiple labels to model


The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist d3yii2/d3labels "*"

or add

"d3yii2/d3labels": "*"

to the require section of your composer.json file.

Define Labels

Migration example

use yii\db\Migration;
use \d3yii2\d3labels\logic\D3Definition;
use d3modules\lietvediba\models\RkInvoice;
use d3system\widgets\ThBadge;
class m190329_095047_invoice_labels extends Migration
    * {@inheritdoc}
    public function safeUp()
         $def = new D3Definition(RkInvoice::class);
         $def->setLabel('Warning label');
    public function safeDown()
        echo "m190329_095047_invoice_labels cannot be reverted.\n";
        return false;


Display Widget

        //'title' => Yii::t('d3labels', 'Labels'), //Optional
        'model' => $model

for GridView D3LabelColumn

$columns[] = [
    'class' => d3yii2\d3labels\components\D3LabelColumn::class,                    
    'model' => $searchModel,
    'label' => Yii::t('d3labels', 'Labels'),
    //'badgeRenderOptions' => ['iconsWithText' => true],

attach to model record

use d3yii2\d3labels\logic\D3Label;