• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Different error message on hitting unique field

Different error message on hitting unique field 4 years 11 months ago #40178

So we've set up a form which has a field with the unique field validation rule. We have also setup a validation error message that reads "Please insert a valid number here", which is correct in most cases.

But in the case of hitting the unique validation rule, that message is misleading, we would like to change the message to something like "Error, you have already made a submission with that ID already".

I guess this will need some scripting, just looking for some tips, thanks!
Last Edit: 4 years 11 months ago by isathens1. Reason: typo
The administrator has disabled public write access.

Different error message on hitting unique field 4 years 11 months ago #40194

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

The simplest approach would be to change your existing validation message to include both cases, for example: "Please insert a valid number here which hasn't been used before".

If however having 2 validation messages is a must, then you can indeed take a custom scripting approach, more precisely "Scripts Called On Form Process" area.

This particular scripting area provides the $invalid variable that can be used to invalidate your fields. You'll basically need to remove your existing validation rule and replicate it within this scripting area (you can query the #__rsform_submission_values table for submitted data); eventually if the ID has also been used, then you can invalidate and change the validation message using something similar as:
//myExactFieldNameHere - this would be the exact name you've given to your field, case sensitive
$myFieldId = RSFormProHelper::getComponentId('myExactFieldNameHere');
$props = &RSFormProHelper::getComponentProperties($myFieldId);
$props['VALIDATIONMESSAGE'] = 'new message here';
$invalid[] = $myFieldId;
This is not official customer support. To receive your support, submit a support ticket here.
Last Edit: 3 years 6 months ago by adrianp. Reason: changed variables naming to be unique
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!