/**
  * @return string
  */
 public function run()
 {
     if ($this->model->hasProperty('mlConfig') and count($this->model->mlConfig['languages']) > 1) {
         return $this->render('index');
     } else {
         return $this->getInputField($this->attribute);
     }
 }
 /**
  * Loads a specific relation with $data.
  * incremental: 		existing subitems are neither removed nor unlinked.
  * non-incremental:		existing (loaded) subitems are unlinked and/or deleted.
  * 
  * @param  ActiveRecord  $model 			model
  * @param  string        $relationName      the relation's name
  * @param  array         $data              data to load, including relational data
  * @param  array         $config            configuration array
  * @internal
  */
 private function setRelation(&$model, $relationName, &$data, &$config)
 {
     if (!$model->hasProperty($relationName)) {
         throw new \yii\base\UnknownPropertyException(sprintf('model {%s} has no relation {%s}', $model->className(), $relationName));
     }
     $relation =& $config[self::RELATIONS][$relationName];
     $formName = ArrayHelper::getValue($relation, self::FORMNAME, false);
     $scenario = ArrayHelper::getValue($relation, self::SCENARIO, $this->defaultScenario);
     $incremental = ArrayHelper::getValue($relation, self::INCREMENTAL, $this->defaultIncremental);
     $delete = ArrayHelper::getValue($relation, self::DELETE, $this->defaultDelete);
     $relationData = $formName == false ? $data : $data[$formName];
     $rel = $model->getRelation($relationName);
     $pattern = new $rel->modelClass();
     $recursive = !$pattern->hasMethod('isActiveDocument');
     $models = null;
     $relation[self::REMOVE] = [];
     $relation[self::LINK] = [];
     // relation is a collection or a single component
     if ($rel->multiple) {
         $models = [];
         if ($incremental) {
             // loop through array data and load sub models
             foreach ($relationData as $key => $value) {
                 $m = $this->loadModel($rel->modelClass, $scenario, $value, $relation, $recursive);
                 $models[] = $m;
             }
         } else {
             $sort = ArrayHelper::getValue($relation, self::SORTABLE, null);
             if ($sort !== null) {
                 $index = 0;
                 foreach ($relationData as $key => &$value) {
                     $relationData[$key][$sort] = $index++;
                 }
             }
             // loop through relation data, load data and detect removable sub models
             foreach ($model->{$relationName} as $item) {
                 $keys = $item->getPrimaryKey(true);
                 // try to find subitem in data
                 reset($relationData);
                 $found = false;
                 foreach ($relationData as $key => &$value) {
                     // normalize
                     if (!empty($formName)) {
                         $value = $value[$formName];
                     }
                     $modelKeys = array_intersect_key($value, $keys);
                     if (count(array_diff_assoc($modelKeys, $keys)) == 0) {
                         $m = $this->loadExistingModel($item, $scenario, $value, $relation, $recursive);
                         $models[] = $m;
                         $found = true;
                         // processed, so remove from data array
                         unset($relationData[$key]);
                         break;
                     }
                 }
                 // we have an existing item, but it was not loaded by $data, so mark for remove.
                 if (!$found) {
                     $relation[self::REMOVE][] = $item;
                 }
             }
             // everything left in $relationData is new model data
             // model might be existing, but not linked
             foreach ($relationData as $key => $value) {
                 // normalize
                 if (!empty($formName)) {
                     $value = $value[$formName];
                 }
                 $m = $this->loadModel($rel->modelClass, $scenario, $value, $relation, $recursive);
                 $models[] = $m;
                 $relation[self::LINK][$this->serializeKey($model)][] = $m;
             }
         }
     } else {
         // relation is a single component
         $oldItem = $model->{$relationName};
         $models = $this->loadModel($rel->modelClass, $scenario, $value, $relation, $recursive);
         if (!$incremental) {
             if ($oldItem !== null) {
                 $keys = $oldItem->getPrimaryKey(true);
                 if ($models !== null) {
                     $modelKeys = $models->getPrimaryKey(true);
                     if (count(array_diff_assoc($keys, $modelKeys)) !== 0) {
                         $relation[self::REMOVE][] = $oldItem;
                     }
                 } else {
                     $relation[self::REMOVE][] = $models;
                 }
             }
         }
     }
     if ($models !== null) {
         $model->populateRelation($relationName, $models);
     }
 }