0

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?

Julius F
  • 3,434
  • 4
  • 29
  • 44

1 Answers1

1

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.

Uraza
  • 556
  • 3
  • 17
  • Apparently it does not work if I pass c.Validation as Pointer an call the function on it in my user Model... – Julius F Apr 15 '14 at 20:21
  • Can you share a more complete example with view, model and controller ? Maybe it would help understand what happens. – Uraza Apr 16 '14 at 05:31