Understanding Validation Conditions

ontarget

Active Member
Hi I am trying to set a condition for a validation I am using the "areuniquevalues" on a field element.
The user have a userid number that they use to make the claim
If a user has previously entered this ID to claim for travel expenses they cant claim for the same thing a second time - hence the comparison between the claim id and user id
Now the caveat!
If the user claimed once and the admin rejected the claim we wish to give them an opportunity to claim again therefore overriding the userid / claimid "areuniquevalues" validation.

in the condition field i have entered this php which says if the row doesnt have a value of "Rejected" then run the areuniquevalues validation - however it doesnt work! Not sure if my php is 100% correct or if i should be adding the if else statement.

PHP:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);

$myQuery
    ->select('calcapprove')
    ->from('aaa_participant_claim')
    ->where('tcn  = ' . $myDb->quote('{aaa_participant_claim___tcn}'))
    ->and('uniqueclaim_id = ' . $myDb->quote('{aaa_participant_claim___uniqueclaim_id}'));

$myDb->setQuery($myQuery);
$rejected = $myDb->loadResult();
if ($rejected != 'Rejected') {
return true;
}
else {
return false;
}
 
Stick this just before the loadResult..

var_dump((string) $myQuery); exit;

... which should show you the query. You may find you need to apoend _raw to your placeholders to get the ids.



Sent from my Pixel 2 XL using Tapatalk
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top