Example #1
0
// view for new object save
func (this *CategoryAdminRouter) Save() {
	form := post.CategoryAdminForm{Create: true}
	if this.ValidFormSets(&form) == false {
		return
	}

	var cat models.Category
	form.SetToCategory(&cat)
	if err := cat.Insert(); err == nil {
		this.FlashRedirect(fmt.Sprintf("/admin/category/%d", cat.Id), 302, "CreateSuccess")
		return
	} else {
		beego.Error(err)
		this.Data["Error"] = err
	}
}
Example #2
0
func (this *CategoryRouter) NewSubmit() {
	form := post.CategoryForm{Locale: this.Locale}
	this.TplNames = "category/new.html"
	if !this.ValidFormSets(&form) {
		return
	}

	var category models.Category

	utils.SetFormValues(&form, &category)

	if err := category.Insert(); err == nil {
		this.Redirect(category.Link(), 302)
	}

}