2017 © Pedro Peláez
 

yii2-extension yii2-eav

EAV for Yii2

image

mazurva/yii2-eav

EAV for Yii2

  • Thursday, August 25, 2016
  • by mazurva
  • Repository
  • 1 Watchers
  • 2 Stars
  • 69 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 45 Forks
  • 0 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

EAV Dynamic Attributes for Yii2

Build Status, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

``` sh php composer.phar require --prefer-dist mazurva/yii2-eav "dev-master", (*4)


or add

"mazurva/yii2-eav": "dev-master", (*5)


to the require section of your `composer.json` file. ``` sh php yii migrate/up --migrationPath=@vendor/mazurva/yii2-eav/src/migrations

Usage

Attach to your model, (*6)

  use EavTrait; // need for full support label of fields

  public function behaviors()
  {
      return [
          'eav' => [
              'class' => mazurva\eav\EavBehavior::className(),
              'valueClass' => mazurva\eav\models\EavAttributeValue::className(), // this model for table object_attribute_value
          ]
      ];
  }

  /**
   * @return \yii\db\ActiveQuery
   */
  public function getEavAttributes()
  {
      return $this->hasMany(mazurva\eav\models\EavAttribute::className(), ['categoryId' => 'id']);
  }

Sample use in view:, (*7)

<?=$form->field($model,'eav2'); ?>

or, (*8)

foreach($model->eavAttributes as $attr){
    echo $form->field($model, $attr->name)->textInput();
}

Add new field:, (*9)

$attr = new mazurva\eav\models\EavAttribute();
$attr->attributes = [
        'categoryId' => 1, // Category ID
        'name' => 'AttrCategory1',  // service name field
        'label' => 'Attr1',         // label text for form
        'defaultValue' => 'attr1',  // default value
        'entityModel' => SampleModel::className(), // work model
        'required'=>false           // add rule "required field"
    ];
$attr->save();

The Versions

25/08 2016

dev-patch-6

dev-patch-6

EAV for Yii2

  Sources   Download

MIT

The Requires

 

by Alien-art

yii2 fields attribute eav cck

28/07 2016

dev-patch-5

dev-patch-5

EAV for Yii2

  Sources   Download

MIT

The Requires

 

by Alien-art

yii2 fields attribute eav cck

28/07 2016

dev-patch-4

dev-patch-4

EAV for Yii2

  Sources   Download

MIT

The Requires

 

by Alien-art

yii2 fields attribute eav cck

28/07 2016

dev-patch-3

dev-patch-3

EAV for Yii2

  Sources   Download

MIT

The Requires

 

by Alien-art

yii2 fields attribute eav cck

27/07 2016

dev-patch-2

dev-patch-2

EAV for Yii2

  Sources   Download

MIT

The Requires

 

by Alien-art

yii2 fields attribute eav cck

11/07 2016

dev-patch-1

dev-patch-1

EAV for Yii2

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 fields attribute eav cck

23/09 2015

dev-master

9999999-dev

EAV for Yii2

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 eav

23/09 2015