public class DynamicForm extends Form<DynamicForm.Dynamic>
HashMap<String,String>| Modifier and Type | Class and Description |
|---|---|
static class |
DynamicForm.Dynamic
Simple data structure used by
DynamicForm. |
Form.Display, Form.Field| Constructor and Description |
|---|
DynamicForm(Map<String,String> data,
List<ValidationError> errors,
Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.Validator validator)
Creates a new dynamic form.
|
DynamicForm(Map<String,String> data,
Map<String,List<ValidationError>> errors,
Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.Validator validator)
Deprecated.
Deprecated as of 2.6.0. Replace the parameter
Map<String,List<ValidationError>> with a simple List<ValidationError>. |
DynamicForm(MessagesApi messagesApi,
Formatters formatters,
javax.validation.Validator validator)
Creates a new empty dynamic form.
|
| Modifier and Type | Method and Description |
|---|---|
DynamicForm |
bind(Map<String,String> data,
String... allowedFields)
Binds data to this form - that is, handles form submission.
|
DynamicForm |
bindFromRequest(Http.Request request,
String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
DynamicForm |
bindFromRequest(String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
Map<String,String> |
data()
Deprecated.
|
ValidationError |
error(String key)
Deprecated.
Deprecated as of 2.6.0. Use
getError(String) instead. |
Form.Field |
field(String key)
Retrieves a field.
|
DynamicForm |
fill(Map<String,Object> value)
Fills the form with existing data.
|
String |
get(String key)
Gets the concrete value only if the submission was a success.
|
Optional<ValidationError> |
getError(String key)
Retrieve an error by key.
|
Map<String,String> |
rawData() |
void |
reject(String key,
String error)
Deprecated.
Deprecated as of 2.6.0. Use
withError(String, String) instead. |
void |
reject(String key,
String error,
List<Object> args)
Deprecated.
Deprecated as of 2.6.0. Use
withError(String, String, List) instead. |
Optional<Object> |
value(String key)
Gets the concrete value
|
DynamicForm |
withError(String key,
String error) |
DynamicForm |
withError(String key,
String error,
List<Object> args) |
allErrors, apply, bind, bindFromRequest, blankInstance, discardErrors, discardingErrors, errors, errors, errorsAsJson, errorsAsJson, fill, get, getArgumentsForConstraint, getBackedType, getGlobalError, getMessageForConstraintViolation, globalError, globalErrors, hasErrors, hasGlobalErrors, name, reject, reject, reject, requestData, toString, value, withError, withGlobalError, withGlobalErrorpublic DynamicForm(MessagesApi messagesApi, Formatters formatters, javax.validation.Validator validator)
messagesApi - the messagesApi component.formatters - the formatters component.validator - the validator component.public DynamicForm(Map<String,String> data, List<ValidationError> errors, Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.Validator validator)
data - the current form data (used to display the form)errors - the collection of errors associated with this formvalue - optional concrete value if the form submission was successfulmessagesApi - the messagesApi component.formatters - the formatters component.validator - the validator component.@Deprecated public DynamicForm(Map<String,String> data, Map<String,List<ValidationError>> errors, Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.Validator validator)
Map<String,List<ValidationError>> with a simple List<ValidationError>.data - the current form data (used to display the form)errors - the collection of errors associated with this formvalue - optional concrete value if the form submission was successfulmessagesApi - the messagesApi component.formatters - the formatters component.validator - the validator component.public String get(String key)
value(String) instead.key - the string key.public Optional<Object> value(String key)
key - the string key.@Deprecated public Map<String,String> data()
data in class Form<DynamicForm.Dynamic>public Map<String,String> rawData()
rawData in class Form<DynamicForm.Dynamic>public DynamicForm fill(Map<String,Object> value)
value - the map of values to fill in the form.public DynamicForm bindFromRequest(String... allowedFields)
bindFromRequest in class Form<DynamicForm.Dynamic>allowedFields - the fields that should be bound to the form, all fields if not specified.public DynamicForm bindFromRequest(Http.Request request, String... allowedFields)
bindFromRequest in class Form<DynamicForm.Dynamic>request - the request to bind data from.allowedFields - the fields that should be bound to the form, all fields if not specified.public DynamicForm bind(Map<String,String> data, String... allowedFields)
bind in class Form<DynamicForm.Dynamic>data - data to submitallowedFields - the fields that should be bound to the form, all fields if not specified.public Form.Field field(String key)
field in class Form<DynamicForm.Dynamic>key - field name@Deprecated public ValidationError error(String key)
getError(String) instead.error in class Form<DynamicForm.Dynamic>key - the field name associated with the error.public Optional<ValidationError> getError(String key)
getError in class Form<DynamicForm.Dynamic>key - the field name associated with the error.@Deprecated public void reject(String key, String error, List<Object> args)
withError(String, String, List) instead.reject in class Form<DynamicForm.Dynamic>key - the error keyerror - the error messageargs - the error argumentspublic DynamicForm withError(String key, String error, List<Object> args)
withError in class Form<DynamicForm.Dynamic>key - the error keyerror - the error messageargs - the error arguments@Deprecated public void reject(String key, String error)
withError(String, String) instead.reject in class Form<DynamicForm.Dynamic>key - the error keyerror - the error messagepublic DynamicForm withError(String key, String error)
withError in class Form<DynamicForm.Dynamic>key - the error keyerror - the error message