1 module uim.html.elements.form; 2 3 import uim.html; 4 5 class DH5Form : DH5Obj { 6 mixin(H5This!"form"); 7 string _targetIFrame; 8 9 /* noValidate - If present, it specifies that the form-data (input) should not be validated when submitted. */ 10 mixin(MyAttribute!("noValidate", "novalidate")); 11 12 /* acceptCharset - Specifies the character encodings that are to be used for the form submission */ 13 mixin(TypeField!("string", "acceptCharset", "AcceptCharset")); 14 15 /* action - Specifies where to send the form-data when a form is submitted */ 16 mixin(TypeField!("string", "action", "Action")); 17 18 /* autoComplete - Specifies whether a form should have autocomplete on or off */ 19 mixin(TypeField!("string", "autoComplete", "Autocomplete")); 20 21 /* encType - specifies how the form-data should be encoded when submitting it to the server */ 22 // mixin(EnumField!("EncTypes", "encType")); 23 24 /* */ 25 void add(Methods value) { _attributes.remove("method"); _attributes["method"] = value; } 26 @property string method() { return _attributes["method"]; } 27 28 /* The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.*/ 29 void add(FormTargets value) { _attributes.remove("target"); if (value != FormTargets.None) { _attributes["target"] = value.toString; } } 30 @property string target() { return _attributes["target"]; } 31 32 // @property auto target(string value) { _targetIFrame = value; target(FormTargets.None); return this; } 33 // protected FormTargets _target; 34 // @property FormTargets target() { return _target; } 35 // @property auto target(FormTargets value) { _target = value; return this; } 36 // // void put(string key, FormTargets value) { attributes[key] = cast(string)value; } 37 // void put(FormTargets value) { target(value); } 38 39 override public string toString() { 40 // if (target != FormTargets.None) set("target", target.toString); 41 // else if (_targetIFrame) set("target", _targetIFrame); 42 // 43 // if (_acceptCharset) set("accept-charset", acceptCharset); 44 // if (_action) set("action", _action); 45 // if (_autoComplete) set("autocomplete", _autoComplete); 46 47 return super.toString; 48 } 49 } 50 mixin(H5Short!"Form"); 51 52 enum FormTargets : string { 53 None = "", 54 Blank = "_blank", // The response is displayed in a new window or tab 55 Self = "_self", //The response is displayed in the same frame (this is default) 56 Parent = "_parent", // The response is displayed in the parent frame 57 Top = "_top" // The response is displayed in the full body of the window 58 } 59 string toString(FormTargets value) { return cast(string)value; } 60 61 enum EncTypes : string { 62 None = "", 63 Application = "application/x-www-form-urlencoded", // (Default) All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values) 64 Multipart = "multipart/form-data", // No characters are encoded. This value is required when you are using forms that have a file upload control 65 Text = "text/plain" 66 } 67 string toString(EncTypes value) { return cast(string)value; } 68 69 enum Methods : string { 70 Get = "get", 71 Post = "post" 72 } 73 string toString(Methods value) { return cast(string)value; } 74 75 unittest { 76 assert(Assert(H5Form,"<form></form>")); 77 }