/** * Retrieves a field. * * @param key field name * @return the field - even if the field does not exist you get a field */ public Field field(String key) { Field field = super.field(asDynamicKey(key)); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value() == null ? get(key) : field.value() ); }
@Override public Form.Field field(String key, Lang lang) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key), lang); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value().orElse(value(key).map(v -> v instanceof String ? (String)v : null).orElse(null)), field.file().orElse(value(key).map(v -> v instanceof Http.MultipartFormData.FilePart ? (Http.MultipartFormData.FilePart)v : null).orElse(null)) ); }
/** * Fills the form with existing data. * @param value the map of values to fill in the form. * @return the modified form. */ public DynamicForm fill(Map<String, Object> value) { Form<Dynamic> form = super.fill(new Dynamic(value)); return new DynamicForm(form.rawData(), form.files(), form.errors(), form.value(), messagesApi, formatters, validatorFactory, config, lang().orElse(null)); }
@Override public DynamicForm withLang(Lang lang) { return new DynamicForm(super.rawData(), super.files(), this.errors(), this.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the errot arguments */ public void reject(String key, String error, List<Object> args) { super.reject(asDynamicKey(key), error, args); }
default FormFactory formFactory() { return new FormFactory(messagesApi(), formatters(), validatorFactory(), config()); } }
/** * Retrieve an error by key. */ public ValidationError error(String key) { return super.error(asDynamicKey(key)); }
import play.data.DynamicForm; import play.data.Form; public static Result cadastraPedidoNoBanco() { DynamicForm form = Form.form().bindFromRequest(); if (form.data().size() == 0) { return badRequest("Expceting some data"); } else { String response = "Client " + form.get("nome_cliente") + "has phone number " + form.get("telefone_cliente"); return ok(response); } }
/** * Retrieves a field. * * @param key field name * @return the field - even if the field does not exist you get a field */ public Form.Field field(String key) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key)); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value() == null ? get(key) : field.value() ); }
@Override public Form.Field field(String key, Lang lang) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key), lang); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value().orElse(value(key).map(v -> v instanceof String ? (String)v : null).orElse(null)), field.file().orElse(value(key).map(v -> v instanceof Http.MultipartFormData.FilePart ? (Http.MultipartFormData.FilePart)v : null).orElse(null)) ); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the errot arguments */ public void reject(String key, String error, List<Object> args) { super.reject(asDynamicKey(key), error, args); }
default FormFactory formFactory() { return new FormFactory(messagesApi(), formatters(), validatorFactory(), config()); } }
/** * Retrieve an error by key. */ public ValidationError error(String key) { return super.error(asDynamicKey(key)); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { super.reject(asDynamicKey(key), error); }
@Override public Optional<ValidationError> error(String key) { return super.error(asDynamicKey(key)); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { super.reject(asDynamicKey(key), error); }