admin icon indicating copy to clipboard operation
admin copied to clipboard

selectionTemplate不起作用

Open themoonstone opened this issue 8 years ago • 0 comments

经过测试,发现用于覆盖select类meta的selectiontemplate没起到作用,下面是代码: `package main

import ( "fmt" "net/http" "github.com/qor/admin" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" )

// Define a GORM-backend model type User struct { gorm.Model Name string }

func main() { // Set up the database conn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=true", "root", "123456", "localhost:3306", "qor_admin") DB, _ := gorm.Open("mysql", conn) DB.AutoMigrate(&User{})

// Initalize
Admin := admin.New(&admin.AdminConfig{DB: DB})

// Create resources from GORM-backend model
user := Admin.AddResource(&User{})
user.Meta(&admin.Meta{
	Name:"Name",
	Type:"select_one",
	Config:&admin.SelectOneConfig{
		Collection:[]string{"1","2"},
		SelectionTemplate:"./ls.tmpl",
	},
})
// Initalize an HTTP request multiplexer
mux := http.NewServeMux()

// Mount admin to the mux
Admin.MountTo("/admin", mux)

fmt.Println("Listening on: 9000")
http.ListenAndServe(":9000", mux)

}` 我ls.tmpl里的内容就是简单的

test

themoonstone avatar Dec 18 '17 08:12 themoonstone