Exemplo n.º 1
0
 public static function relation(ActiveRecord $model, $relation_name, $options = [])
 {
     /* @var ActiveRecord|YcmModelUtilTrait $model */
     $relation = $model->getRelation($relation_name);
     $config = [$relation_name, 'widget', 'widgetClass' => Select2::className(), 'data' => RelationHelper::getSelectChoices($model, $relation_name), 'hideSearch' => false, 'options' => ['multiple' => $relation->multiple, 'placeholder' => 'Select...'], 'pluginOptions' => ['allowClear' => true]];
     return ArrayHelper::merge($config, $options);
 }
Exemplo n.º 2
0
 public static function relation(ActiveRecord $model, $relation_name, $options = [])
 {
     /* @var ActiveRecord|YcmModelUtilTrait $model */
     $label = strpos($relation_name, $model->relations_delimeter) !== false ? substr($relation_name, strrpos($relation_name, $model->relations_delimeter) + strlen($model->relations_delimeter)) : $relation_name;
     $config = ArrayHelper::merge(['label' => $label, 'attribute' => $relation_name], self::selectWidgetFilterConfig(RelationHelper::getSelectChoices($model, $relation_name)));
     return ArrayHelper::merge($config, $options);
 }