Adding input mask for the text fields. You have to create them yourself with mask in the text element
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1081436 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1160,6 +1160,9 @@ under the License.
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="mask" type="xs:string">
|
||||
<xs:annotation><xs:documentation>Defines a customized input mask. Use 9 for numeric, a for alpha and * for alphanumeric character.</xs:documentation></xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:attributeGroup>
|
||||
<xs:element name="textarea" substitutionGroup="AllFields">
|
||||
<xs:complexType>
|
||||
|
||||
@@ -333,6 +333,7 @@ public class MacroFormRenderer implements FormStringRenderer {
|
||||
String name = modelFormField.getParameterName(context);
|
||||
String className = "";
|
||||
String alert = "false";
|
||||
String mask = "";
|
||||
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
|
||||
className = modelFormField.getWidgetStyle();
|
||||
if (modelFormField.shouldBeRed(context)) {
|
||||
@@ -357,6 +358,10 @@ public class MacroFormRenderer implements FormStringRenderer {
|
||||
clientAutocomplete = "true";
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(textField.getMask())) {
|
||||
mask = textField.getMask();
|
||||
}
|
||||
|
||||
String ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
|
||||
boolean disabled = textField.disabled;
|
||||
|
||||
@@ -393,7 +398,9 @@ public class MacroFormRenderer implements FormStringRenderer {
|
||||
sr.append(ajaxUrl);
|
||||
sr.append("\" ajaxEnabled=");
|
||||
sr.append(Boolean.toString(ajaxEnabled));
|
||||
sr.append(" />");
|
||||
sr.append(" mask=\"");
|
||||
sr.append(mask);
|
||||
sr.append("\" />");
|
||||
executeMacro(writer, sr.toString());
|
||||
|
||||
ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink();
|
||||
|
||||
@@ -2833,6 +2833,7 @@ public class ModelFormField {
|
||||
protected SubHyperlink subHyperlink;
|
||||
protected boolean disabled;
|
||||
protected boolean clientAutocompleteField;
|
||||
protected String mask;
|
||||
|
||||
protected TextField() {
|
||||
super();
|
||||
@@ -2849,6 +2850,7 @@ public class ModelFormField {
|
||||
public TextField(Element element, ModelFormField modelFormField) {
|
||||
super(element, modelFormField);
|
||||
this.setDefaultValue(element.getAttribute("default-value"));
|
||||
this.mask = element.getAttribute("mask");
|
||||
|
||||
String sizeStr = element.getAttribute("size");
|
||||
try {
|
||||
@@ -2943,6 +2945,10 @@ public class ModelFormField {
|
||||
public void setSubHyperlink(SubHyperlink newSubHyperlink) {
|
||||
this.subHyperlink = newSubHyperlink;
|
||||
}
|
||||
|
||||
public String getMask() {
|
||||
return this.mask;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TextareaField extends FieldInfo {
|
||||
|
||||
@@ -24,7 +24,7 @@ under the License.
|
||||
</#macro>
|
||||
<#macro renderHyperlinkField></#macro>
|
||||
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled><@renderField value /></#macro>
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask><@renderField value /></#macro>
|
||||
|
||||
<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@renderField value /></#macro>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ under the License.
|
||||
</#macro>
|
||||
<#macro renderHyperlinkField></#macro>
|
||||
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled><@makeBlock className value /></#macro>
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask><@makeBlock className value /></#macro>
|
||||
|
||||
<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@makeBlock className value /></#macro>
|
||||
|
||||
|
||||
@@ -48,7 +48,12 @@ under the License.
|
||||
</#macro>
|
||||
<#macro renderHyperlinkField></#macro>
|
||||
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled>
|
||||
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask>
|
||||
<#if mask?has_content>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($){jQuery("#${id}").mask("${mask}");});
|
||||
</script>
|
||||
</#if>
|
||||
<input type="text" name="${name?default("")?html}"<#t/>
|
||||
<@renderClass className alert />
|
||||
<#if value?has_content> value="${value}"</#if><#rt/>
|
||||
|
||||
Reference in New Issue
Block a user