Form plugin - conditional statement does not work

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.

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
$count < $representativesLimit
the error message does show (even when $count is larger):
ERROR: You tried to register more people than the registration limit! Count: 1 representativesLimit: 3

What am I doing wrong?
 
Use var_dump($xy);exit; or dump($xy); (with the jdump extension) to see what you get in your variables.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top