/** * Sets given attributes unsafe * @param array $scenarios * @param string $name scenario name * @param array $attrs given attrs */ protected function setAttributesUnsafe(&$scenarios, $name, array $attrs = []) { GxModelHelper::setAttributesUnsafe($scenarios, $name, $attrs); }
/** * @inheritdoc */ public function rules() { $rules = parent::rules(); GxModelHelper::removeValidationRules($rules, 'required', ['queryNs']); GxModelHelper::removeValidationRules($rules, 'validateMessageCategory', ['messageCategory']); GxModelHelper::removeValidationRules($rules, 'validateModelClass', ['modelClass']); return ArrayHelper::merge([[['modelClass'], 'validateModelClass', 'skipOnEmpty' => true], [['recordPrintAttr'], 'validateRecordPrintAttr', 'skipOnEmpty' => true], [['messageCategory'], 'validateMessageCategory', 'skipOnEmpty' => true], [['generateMutation', 'generateSluggableBehavior', 'sluggableBehaviorEnsureUnique', 'sluggableBehaviorImutable', 'generateTimestampBehavior', 'generateGalleryBehavior', 'generateSortableBehavior'], 'boolean'], [['mutationJoinTableName', 'mutationSourceTableName'], 'filter', 'filter' => 'trim'], [['mutationJoinTableName', 'mutationSourceTableName'], 'required', 'when' => function ($model) { return $model->generateMutation; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatemutation').is(':checked');\n }"], [['mutationIgnoredFormAttributes'], 'validateAttributeExistence', 'params' => ['tblAttr' => 'mutationJoinTableName'], 'when' => function ($model) { return trim($model->mutationIgnoredFormAttributes); }], [['mutationJoinTableName', 'mutationSourceTableName'], 'match', 'pattern' => '/^(\\w+\\.)?([\\w\\*]+)$/', 'message' => 'Only word characters, and optionally an asterisk and/or a dot are allowed.'], [['mutationJoinTableName', 'mutationSourceTableName'], 'validateTableName'], [['sluggableBehaviorSourceAttribute', 'sluggableBehaviorTargetAttribute'], 'required', 'when' => function ($model) { return $model->generateSluggableBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatesluggablemutation').is(':checked');\n }"], [['sluggableBehaviorSourceAttribute', 'sluggableBehaviorTargetAttribute'], 'validateAttributeExistence', 'params' => ['tblAttr' => 'tableName'], 'when' => function ($model) { return $model->generateSluggableBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatesluggablemutation').is(':checked');\n }"], [['timestampCreatedAtAttribute', 'timestampUpdatedAtAttribute'], 'validateAttributeExistence', 'params' => ['tblAttr' => 'tableName'], 'when' => function ($model) { return $model->generateTimestampBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatetimestampbehavior').is(':checked');\n }"], [['timestampCreatedAtAttribute', 'timestampUpdatedAtAttribute'], 'required', 'when' => function ($model) { return $model->generateTimestampBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatetimestampbehavior').is(':checked');\n }"], [['sortableIndexAttribute', 'sortableRestrictionsAttribute', 'sortableKeyAttribute'], 'string'], [['sortableColumnAttribute'], 'validateAttributeExistence', 'params' => ['tblAttr' => 'tableName'], 'when' => function ($model) { return $model->generateSortableBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatesortablebehavior').is(':checked');\n }"], [['sortableIndexAttribute', 'sortableColumnAttribute'], 'required', 'when' => function ($model) { return $model->generateSortableBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generatesortablebehavior').is(':checked');\n }"], [['galleryTableName'], 'filter', 'filter' => 'trim'], [['galleryTableName'], 'validateTableName', 'when' => function ($model) { return $model->generateGalleryBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generategallerybehavior').is(':checked');\n }"], [['galleryTableName'], 'required', 'when' => function ($model) { return $model->generateGalleryBehavior; }, 'whenClient' => "function (attribute, value) {\n return \$('#generator-generategallerybehavior').is(':checked');\n }"]], $rules); }