emcguire
Member
Guys,
I am trying to validate a form based on comparing 2 (int) values and it just keeps returning false.
In my form I have a databasejoin element with and "account type limit" and a databasejoin element with "# of account types"
So basically when a user selects a certain category, whn submitting I need to check those 2 dbjoin values, if the "# of the account type" is greater than the "account type limit" it needs to return false. I can't get it to validate no matter what. It always returns false (even when it shouldn't)
here is what I have in the validation "PHP code" on the category type field.
so in my form, I have the 2 dbjoin elements with the "limit" and the "# of accounts", then on submit, I just need to compare the two, if the "# of accounts" is higher than the "limit" is needs to stop them.
What am I doing wrong here?
I am trying to validate a form based on comparing 2 (int) values and it just keeps returning false.
In my form I have a databasejoin element with and "account type limit" and a databasejoin element with "# of account types"
So basically when a user selects a certain category, whn submitting I need to check those 2 dbjoin values, if the "# of the account type" is greater than the "account type limit" it needs to return false. I can't get it to validate no matter what. It always returns false (even when it shouldn't)
here is what I have in the validation "PHP code" on the category type field.
PHP:
$tar_lim_value = $formModel->formData['target_limit_raw'][0];
$elementModel = $formModel->getElement('nab_accounts___target_limit');
$target_limit = $elementModel->getEmailValue($tar_lim_value, $formModel->formDataWithTableName, 0);
$tar_acct_value = $formModel->formData['target_accounts_raw'][0];
$elementModel = $formModel->getElement('nab_accounts___target_accounts');
$target_accts = $elementModel->getEmailValue($tar_acct_value, $formModel->formDataWithTableName, 0);
if $target_accts > $target_limit {
return false;
}
return true;
so in my form, I have the 2 dbjoin elements with the "limit" and the "# of accounts", then on submit, I just need to compare the two, if the "# of accounts" is higher than the "limit" is needs to stop them.
What am I doing wrong here?