Crud : add ability to add custom fields in the form
Bug #507978 reported by
hugo lassiège
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
play framework | Status tracked in 1.0 | |||||
1.0 |
Fix Released
|
Undecided
|
Unassigned | |||
1.1 |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
Hi,
I would like to add some fields in a form that were not in the model object.
My purpose was to add some custom fields in the form. My common use case is a form to create a user. The field "confirmPassword" is not a field in the model but I would like to add it in the form (and handle it in the save method, I don't know how for the moment).
#{crud.custom 'confirmPassword'}
... some code to display the confirm password
#{/crud.custom}
Or maybe you have some other ideas ?
To post a comment you must log in.
well... you can create a transient field, so that field will not be persisted in your database, your User model would be like this:
@Entity
public class User extends Model {
@Email
@Required
public String email;
@Required "passwordConfir mation" )
@Password
@Equals(
//another fields...
}
-------
and your view like this:
#{crud.form}
#{crud.custom 'password'}
<label for="object_ password" >&{'password' }</label> password" name="object. password" value="">
<input type="password" id="object_
<label for="object_ passwordConfirm ation"> &{'passwordConf irmation' }</label> passwordConfirm ation" name="object. passwordConfirm ation">
<input type="password" id="object_
#{/crud.custom}
#{/crud.form}