title: creating dynamic html form
body: <p>Trying to learn how to create a dynamic html form. The elements would be defined in the database. Once page is created, the post back data will be handled by controller to insert the data into the database.</p>
  
  <p>I am using playframework 1.2.4</p>
  
  <p>would appreciate any guideline/ helpful links</p>
  
  <p>I can build the page if i know what the elements are and can pull data out for select list from a database table when i call render(param object) from my controller and access the object in my view.</p>
  
  <p>My hack so far:
  Created a table with following columns</p>
  
  <pre><code>rid
  HTMLElementType
  ElementName
  HTMLElementOptions [if the element type is select]
  HTMLDefaultValue [default value for select like 'select a value from below']
  HTMLElementEnabled
  </code></pre>
  
  <p>Created a model</p>
  
  <pre><code>package models;
  
  import play.*;
  import play.db.jpa.*;
  import play.data.validation.*;
  
  import javax.persistence.*;
  import java.util.*;
  
  @javax.persistence.Entity
  @Table(name="mytable")
  public class DynameForm extends Model{
       public String HTMLElementType;
       public String ElementName;
       public String HTMLElementOptions;
       public String HTMLDefaultValue;
       public String HTMLElementEnabled;
  }
  </code></pre>
  
  <p>In my view i loop through checking if it a <code>&lt;select&gt;</code> and if so put in an empty option. But not sure if that is right way to go about. In addition in my view i also have to check if it is not  then i have to put in <code>&lt;input type=&gt;</code> and build the complete tag</p>
  
  <p>In addition how would I enforce validation on certain fields that are required like example last name/ ssn/ etc? I can alter my table to have a column IsRequired which could help me</p>
  
  <p>Not sure what the right way even is to capture the data on post back</p>