Collection Edit
Collection edit is generated by has many
associations automatically. For example, a hypothetical project's 'Product' that has many ColorVariations may be setup as follows:
type Product struct {
gorm.Model
Name string
Description string
ColorVariations []ColorVariation
}
type ColorVariation struct {
gorm.Model
ProductID uint
Product Product
ColorName string
ColorCode string
}
QOR will generate a sub-form inside the 'Product' section of QOR Admin, it is displayed in a slide-out sheet[1]:
Customize fields inside nested form
You can customize attribute of Parameter resource by:
product := Admin.AddResource(&Product{})
colorVariationRes := product.Meta(&admin.Meta{Name: "ColorVariation"}).Resource
colorVariationRes.NewAttrs("ColorName", "ColorCode")
colorVariationRes.EditAttrs("ColorCode")
Configuration
type CollectionEditConfig struct {
Template string
Max uint
}
Template
Template accept a file path to overwrite default collection edit template, which usually used when writing plugins to customize collection edit's template.
Refer sorting for collection edit as an example.
Max
Maximum count of records could be created with collection edit.
[1] note: slide-out sheet is not an official Material Design element, but we think it really helps maintain context when editing!