dongshandun4363 2014-04-14 18:34
浏览 31

狂欢的.flash和.error

I installed the booking app and build a small app by myself and both suffer from the inability of displaying flash errors as shown here: https://github.com/revel/revel/blob/master/samples/booking/app/views/hotels/settings.html

The example view I use in my own app is https://gist.github.com/daemonfire300/10581488 and iterating over .error works perfectly fine.

Am I missing something?

  • 写回答

1条回答 默认 最新

  • douguai6716 2014-04-15 06:49
    关注

    I wrote a controller like this (please note that I used the default App instead of the UserController that you use in your example):

    type User struct {
        Username string
        Password string
        Email    string
    }
    
    func (c App) Register(user User) revel.Result {
        c.Validation.Required(user.Username).Message("Missing username")
        c.Validation.Required(user.Password).Message("Missing password")
        c.Validation.Required(user.Email).Message("Missing email")
        if c.Validation.HasErrors() {
            c.Validation.Keep()
            c.FlashParams()
        }
        return c.Redirect(App.Index)
    }
    

    When I miss a field on the form (for example the password), I do get the errors and all previous fields' values are restored, as shown here.

    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用