20], [['name', 'css'], 'string', 'max' => 30], [['pattern', 'error_tips', 'form_attribute', 'unset_group_ids', 'unset_role_ids'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'field_id' => Yii::t('attr','content_model_field.field_id'), 'model_id' => Yii::t('attr','content_model_field.model_id'), 'field' => Yii::t('attr','content_model_field.field'), 'name' => Yii::t('attr','content_model_field.name'), 'tips' => Yii::t('attr','content_model_field.tips'), 'css' => Yii::t('attr','content_model_field.css'), 'min_length' => Yii::t('attr','content_model_field.min_length'), 'max_length' => Yii::t('attr','content_model_field.max_length'), 'pattern' => Yii::t('attr','content_model_field.pattern'), 'error_tips' => Yii::t('attr','content_model_field.error_tips'), 'form_type' => Yii::t('attr','content_model_field.form_type'), 'setting' => Yii::t('attr','content_model_field.setting'), 'form_attribute' => Yii::t('attr','content_model_field.form_attribute'), 'unset_group_ids' => Yii::t('attr','content_model_field.unset_group_ids'), 'unset_role_ids' => Yii::t('attr','content_model_field.unset_role_ids'), 'is_core' => Yii::t('attr','content_model_field.is_core'), 'is_system' => Yii::t('attr','content_model_field.is_system'), 'is_unique' => Yii::t('attr','content_model_field.is_unique'), 'is_base' => Yii::t('attr','content_model_field.is_base'), 'is_search' =>Yii::t('attr','content_model_field.is_search'), 'is_order' => Yii::t('attr','content_model_field.is_order'), 'is_add' => Yii::t('attr','content_model_field.is_add'), 'is_add_admin' => Yii::t('attr','content_model_field.is_add_admin'), 'is_fullsearch' => Yii::t('attr','content_model_field.is_fullsearch'), 'is_position' => Yii::t('attr','content_model_field.is_position'), 'is_omnipotent' => Yii::t('attr','content_model_field.is_omnipotent'), 'is_listshow' => Yii::t('attr','content_model_field.is_listshow'), 'list_order' => Yii::t('attr','content_model_field.list_order'), 'disabled' => Yii::t('attr','content_model_field.disabled'), ]; } /*返回可选择的字段类型 * $_GET['id'] 不为空时是在修改字段 */ public function getFormTypes() { $all_field = array(); $model_id = intval(Yii::$app->request->get('model_id')); if(empty($model_id))return; $f_datas = ContentModelField::find()->where("model_id=:model_id",[':model_id'=>$model_id])->orderBy(['list_order' => SORT_ASC])->all();; if(is_array($f_datas))foreach($f_datas as $o) { $exists_field[] = $o->field; } $all_field = array(); $fields = FormElements::getFieldsInfo('types'); $not_allow_fields = FormElements::getFieldsInfo('not_allow_fields'); $unique_fields = FormElements::getFieldsInfo('unique_fields'); if(empty($_GET['id'])) { foreach($fields as $_k=>$_v) { if((is_array($not_allow_fields)&&in_array($_k,$not_allow_fields)) || (is_array($exists_field)&&in_array($_k,$exists_field)) && (is_array($unique_fields)&&in_array($_k,$unique_fields))) continue; $all_field[$_k] = $_v; } } else { foreach($fields as $_k=>$_v) { $all_field[$_k] = $_v; } } return $all_field; } }