Exemplo n.º 1
0
 private function renderField($model, $attribute, $options)
 {
     $this->adjustLabelFor($options);
     $eavModel = EavModel::create(['entityModel' => $model, 'attribute' => $attribute, 'valueClass' => \mirocow\eav\models\EavAttributeValue::className()]);
     $handler = $eavModel->handlers[$attribute];
     $handler->owner->activeForm = $options['form'];
     unset($options['form']);
     $handler->options = $options;
     /** @var EavAttribute $attributeModel */
     $attributeModel = $handler->attributeModel;
     /** @var ActiveField $model */
     $model = $handler->run();
     $model->label($attributeModel->label);
     $model->hint($attributeModel->description);
     $this->parts = $model->parts;
     /** Add required attribute */
     if ($attributeModel->required) {
         $this->options['class'] .= ' ' . $this->form->requiredCssClass;
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEavAttributeValues()
 {
     return $this->hasMany(EavAttributeValue::className(), ['attributeId' => 'id']);
 }