gws.plugin.model_field.related_feature¶
Related feature field.
Represents a child->parent M:1 relationship to another model:
+-------------+ +--------------+
| model | | toModel |
+-------------+ +--------------+
| fromColumn |-------->| toColumn |
+-------------+ +--------------+
The value of the field is the parent feature. fromColumn is the foreign
key column in this model’s table, toColumn the key column in the related
model, by default its primary key. When a feature is written, the key of the
selected parent feature is stored in fromColumn. When a parent feature is
created together with a child feature, the child’s fromColumn is set to
the new parent’s key. Without a configured widget, the field uses a
featureSelect widget.
Example:
fields+ {
name "category"
type "relatedFeature"
fromColumn "category_id"
toModel "model_category"
toColumn "id"
widget.type "featureSelect"
}
Source code: gws.plugin.model_field.related_feature
Package Contents¶
- class gws.plugin.model_field.related_feature.Config¶
Bases:
gws.base.model.related_field.ConfigField referring to a feature in another model.
- class gws.plugin.model_field.related_feature.Object¶
Bases:
gws.base.model.related_field.ObjectRelated feature field object.
- attributeType¶
- after_create_related(dst_feature, mc)¶
- after_select(features, mc)¶
- before_create(feature, mc)¶
- before_update(feature, mc)¶
- before_write(feature: gws.Feature, mc: gws.ModelContext)¶
Write the key of the related feature to the foreign key column of the record.
Does nothing if the user may not write the field or the feature has no value for it. An empty value clears the foreign key.
- Parameters:
feature – The feature being created or updated.
mc – The model context.
- configure_relationship()¶
- do_init(feature, mc)¶
- uids_for_key(rel: gws.base.model.related_field.RelRef, key, mc)¶
Find the uids of the features whose key column has the given value.
- Parameters:
rel – The relationship side to query.
key – The key value.
mc – The model context.
- Returns:
A set of feature uids as strings.
- class gws.plugin.model_field.related_feature.Props¶