1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Understanding Validation Conditions

Discussion in 'Community' started by ontarget, Dec 5, 2018.

  1. ontarget

    ontarget Member

    Level: Community
    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.

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

        ->where('tcn  = ' . $myDb->quote('{aaa_participant_claim___tcn}'))
        ->and('uniqueclaim_id = ' . $myDb->quote('{aaa_participant_claim___uniqueclaim_id}'));

    $rejected = $myDb->loadResult();
    if ($rejected != 'Rejected') {
    return true;
    else {
    return false;
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
  3. ontarget

    ontarget Member

    Level: Community
    Thanks Hugh
    I will give that a whirl

Share This Page