• 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: Validation rule - how to notice only

Validation rule - how to notice only 7 years 5 months ago #37597

  • Paladin
  • Paladin's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
RSForm Pro has an excellent set of default and custom validation rules.
But if a validation rule set against a field - it's not possible to add a submission until validation rule is performed.
Mainly it's a correct logic.

BUT ! Very often we meet a scenario when we need only an information notice to user, not a strict prohibition to submit a form.
For example, a validation rule "uniquefielduser" from
/components/com_rsform/helpers/validation.php

If we set this validation rule - user can't submit a RSform at all.
But we need just a notice - something like "such a value already exists in our database" - but ALLOW a user to submit a form anyway.
This is still the weak point of RSForm Pro.

So, two questions here
1) Could RSForm developer team add a feature "Notice only against a validation rule" to next release ?

2) Is it possible right now to customize the code from
/components/com_rsform/helpers/validation.php
to issue only notice ?
For example this one below :
	public static function uniquefielduser($value, $extra=null,$data=null)
	{
		$db 		= JFactory::getDbo();
		$app		= JFactory::getApplication();
		$form   	= $app->input->get('form', array(), 'array');
		$formId 	= isset($form['formId']) ? $form['formId'] : 0;
		$user		= JFactory::getUser();
		$userField 	= $user->guest ? 's.UserIp' : 's.UserId';
		$userValue 	= $user->guest ? $app->input->server->getString('REMOTE_ADDR') : $user->id;
		$option 	= $app->input->getCmd('option');
		$ctrl 		= $app->input->getCmd('controller');
		$task 		= $app->input->getCmd('task');
		$id			= $app->input->getInt('id');
 
		$query = $db->getQuery(true)
			->select($db->qn('sv.SubmissionValueId'))
			->from($db->qn('#__rsform_submission_values', 'sv'))
			->join('left', $db->qn('#__rsform_submissions', 's').' ON ('.$db->qn('sv.SubmissionId').' = '.$db->qn('s.SubmissionId').')')
			->where($db->qn('sv.FormId').'='.$db->q($formId))
			->where($db->qn('sv.FieldName').'='.$db->q($data['NAME']))
			->where($db->qn('sv.FieldValue').'='.$db->q($value));
 
		// Is this a directory edit?
		if ($id && $option == 'com_rsform' && $ctrl == 'directory' && ($task == 'save' || $task == 'apply')) {
			$query->where($db->qn('s.SubmissionId').' != '.$db->q($id));
 
			// Override the $userValue based on the submission original values
			$newquery = $db->getQuery(true)
				->select($db->qn('UserId'))
				->select($db->qn('UserIp'))
				->from($db->qn('#__rsform_submissions'))
				->where($db->qn('SubmissionId').'='.$db->q($id));
 
			$submission = $db->setQuery($newquery)->loadObject();
			if ($submission->UserId) {
				$userField = 's.UserId';
				$userValue = $submission->UserId;
			} else {
				$userField = 's.UserIp';
				$userValue = $submission->UserIp;
			}
		}
 
		$query->where($db->qn($userField).'='.$db->q($userValue));
 
		return $db->setQuery($query)->loadResult() ? false : true;
	}

Waiting for a comment,
Thanks in advance for attention !
Regards,
Serge
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!