• 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: Limit Submissions Based on a Form Field

Limit Submissions Based on a Form Field 8 years 2 weeks ago #36739

I have a need to limit submissions based on a form field value. We have a form that allows our patrons to recommend titles for our collection. We want to limit them to 2 recommendations based on their library card number. What I have right now:

$max = 2;
$db = JFactory::getDbo();
$cardnumber = $_POST;
$db->setQuery("SELECT COUNT(`FieldValue`) FROM `#__rsform_submission_values` WHERE `FieldName`='librarycardnumber' AND `FieldValue`='".$cardnumber."' AND `FormId`=13");
$count = $db->loadResult();
if( $count >= $max ){
$invalid[] = RSFormProHelper::getComponentId("librarycardnumber", "13");
}

This works fine, but we also have to validate the library card number, so it looks a little awkward to have "Please complete all required fields" and the Library Card field with the message "Sorry, this is an invalid library card number or you have exceeded the total number of requests allowed" when the card number is valid and the patron has exceeded the maximum requests. It would be better if I could stop the database update when the form is submitted, and display a message rather than re-displaying the form with the invalid field message. Is this possible?

Thank you,
Anthony
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!