Hi,
Sylvain Wallez wrote:
Mark Lundquist wrote:
Sometimes you just really want to say
someWidget.required = false;
in flowscript. Why shouldn't that be possible?
I attached a path for the field widget which makes this possible :-)
What's the way to do the same thing for label, help and hint, since they
are all stored in a Map?
I've seen several requests also to be able to change a field's label.
That one is a bit more complicated in Ajax scenarios because the label
and field are handled separately in the form template. But certainly
doable!
Would it also be possible to do a binding of a field's required, label,
help, hint or even validation elements?
Philipp
Index: org/apache/cocoon/forms/formmodel/Field.java
===================================================================
--- org/apache/cocoon/forms/formmodel/Field.java (Revision 332014)
+++ org/apache/cocoon/forms/formmodel/Field.java (Arbeitskopie)
@@ -62,6 +62,8 @@
protected String enteredValue;
protected Object value;
+ protected boolean required;
+
/**
* Value state indicating that a new value has been read from the request,
* but has not yet been parsed.
@@ -136,6 +138,7 @@
setValue(value);
}
this.selectionList = this.fieldDefinition.getSelectionList();
+ this.required = this.fieldDefinition.isRequired();
super.initialize();
}
@@ -360,7 +363,7 @@
this.validationError = null;
try {
- if (this.value == null && getFieldDefinition().isRequired()) {
+ if (this.value == null && this.required) {
// Field is required
this.validationError = new ValidationError(new
I18nMessage("general.field-required", FormsConstants.I18N_CATALOGUE));
} else if (!super.validate()) {
@@ -404,9 +407,21 @@
}
public boolean isRequired() {
- return getFieldDefinition().isRequired();
+ return this.required;
}
+ public void setRequired() {
+ setRequired(true);
+ }
+
+ public boolean getRequired() {
+ return this.required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
/**
* @return "field"
*/