Luculentus
New Member
Hi,
I have a multi page form with two groups. I added a php form plugin to check if the number of elements there are in the repeatable group (counting how many repeatable groups are added) is bigger than the value in another element in the other group. If true, I want the submission to abort and show an error message.
The element "representatives___registration_limit" is cascadingdropdown and the element "participant___id" is internalid.
The form is saved and the error message does not show if I run the code above when"representatives___registration_limit" value is 3 and the value of $count is 4.
If I change the condition to
What am I doing wrong?
I have a multi page form with two groups. I added a php form plugin to check if the number of elements there are in the repeatable group (counting how many repeatable groups are added) is bigger than the value in another element in the other group. If true, I want the submission to abort and show an error message.
PHP:
$participantId = explode(",", '{participant___id}');
$representativesLimit = '{representatives___registration_limit_raw}';
$count = count($participantId);
if($count > $representativesLimit){
$formModel->setFormErrorMsg("ERROR: You tried to register more people than the registration limit! Count: ". $count . " representativesLimit: ". $representativesLimit ."");
return false;
}
The element "representatives___registration_limit" is cascadingdropdown and the element "participant___id" is internalid.
The form is saved and the error message does not show if I run the code above when"representatives___registration_limit" value is 3 and the value of $count is 4.
If I change the condition to
the error message does show (even when $count is larger):$count < $representativesLimit
ERROR: You tried to register more people than the registration limit! Count: 1 representativesLimit: 3
What am I doing wrong?