Play framework form validation errors

I post as I work my way through the Play material. I have not still read The reactive manifesto and relate it to Play. So I used the same classic trick popularized by Struts to debug this. As far as this type of error display mechanism is concerned I did not find anything different between Play and old versions of Struts.


I did not initialize isApproved to false.

package models;

import javax.persistence.*;
import javax.validation.Valid;

import play.db.ebean.*;

@Entity public class Proposal extends Model {

	public String id;
	@Required public String title;
	@MinLength(value = 10)
	@MaxLength(value = 1000)
	public String proposal;
	@Required public SessionType type = SessionType.OneHourTalk;
	@Required public Boolean isApproved;
	public String keywords;
	public Speaker speaker;

Display errors


@import helper._

@main("New Proposal"){

	@if(proposal.hasErrors) {
        <div class="alert alert-error">

	@form(action = routes.MainController.submitProposal()){
	<p class="submit">
				<button type="submit" class="button green" id="submitForm">Submit</button>

Error message

I can customize it but this sufficed.

Screen Shot 2014-02-23 at 5.14.17 PM

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: