In Confiforms I have a number of fields for which I want to apply the same validation rule(s). I don't want these permanently part of the Field Definition macro for each field, as I want to be able to turn the validation on or off based on the value of a checkbox.
I am able to do this using a 'Confiforms Rules for Field Definition' macro, with a 'Validation rule' action, and listing all the fields I want to apply it to.
This seems to be working, and displays the error message on Save.
However, I would like the error message to include the name of the field that triggers the validation error. (I'm OK if it displays 10 error messages if there are 10 fields that fail validation, but I would like each error message to include the name of the affected field.)
Is there a way to do this?
Generally the idea is to set specific validation for each field you need and this allows you to show unique error messages specific to these validation rules
If you put the field names into the validation rule (first parameter on the macro), as comma separated list and when validation gets applied you will see these fields marked/highlighted with "red" border
This is what is possible at the moment.
Otherwise split your validation rules into different ConfiForms Field Definition Rules macros with unique validation rules and error messages
Alex
Yes, I have done that with several rules (one rule per field) ... but in this case I want to apply the same rule to a large number of fields.
I forgot about the highlighting in red, and that works fine for this case!
(It would be a slight problem if there might be multiple validation errors that each applied to multiple fields ... as it would be unclear to the user which error message applied to which highlighted fields. But I think I can avoid that by writing the validation rules carefully.)
Thanks again, Alex! As always, this is a brilliant plug-in, and you support it well!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, another place something like this would be useful is in a universal rule to replace one value with another.
E.g. if I want a rule that detects when a user changes a field value to Foo, and change it to Bar ... and then apply that rule to 15 different fields ... then I have to create 15 separate rules, one for each field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why to create 15 separate rules if can have a rule that sets multiple fields at a time?
https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Setvalue can set multiple fields without any problem
field1=some value&field2=another value&field3=1
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since the rule is dependent on the current value of the field, I can't apply the same rule to other fields.
E.g. it watches field1, and when field1=Foo, then change the value of field1 to Bar. Same with field2. Same with field3.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can set the same rule to watch multiple fields - given their names in a comma separated list (first parameter in the macro)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, but if field1 changes, I don't want to change field2.
Example: Imagine that all of these are Status fields, and I want a rule that says "if user changes the value to COMPLETED, then automatically change it to CLOSED." I can list all the fields to watch in a comma-separated list (field1, field2, field3) ... but if user changes field1 to COMPLETED, then I don't want to apply the same change (change it to CLOSED) to field2, field3, etc.
I can do this by creating a separate rule for each field. But it would be nice if I could write the conditional in a way that references "value of this field."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.