PlayFramework validation error message customisation -
i have simple html form in play template field definition below:
<div class="form-group"> <h3>description</h3> <label for="description" class="sr-only">description @for(error <- form("description").errors) { <p>@error.message</p> } </label> <textarea class="form-control" rows="4" name="description"></textarea> </div>
in corresponding model, have @required
annotation on description field this:
@required(message="model.description") public string description;
in conf/messages
, following defined:
model.description=please provide description
when run application , supply empty value, empty value marked error framework. however, error message see (generated html view->source in browser):
<label for="description" class="sr-only">description <p>model.description</p> </label>
so seems message key in annotation not being resolved.what doing wrong?
thank in advance.
update: added following in controller see if conf/messages file being picked up:
system.out.println(messages.get("model.description"));
it generated following output in console:
please provide description
so, messages file being picked up. form still display lookup key.
have tried changing line:
<p>@error.message</p>
to:
<p>@messages.get(error.message)</p>
Comments
Post a Comment