Dec 05, 2013; 11:44
Patrick Larkin
Array size confusion
Hello -
I have a form and items are in groups. When the form is submitted, the code checks to make sure you selected at least one item in a group. If you missed a group, it adds the group number to a variable with a comma. So if there are 5 groups, the error variable may look like this:
1,3,5
Then on the next page, I do a
var('errors') = $error_marker->(split:',');
Which I think makes it an array. Bear with me here.
errors = array((1),(3),(5))
Then further down the page I iterate through the array and show error messages to the end user:
[if(var('errors')->Size > 1)]
<div class="alert alert-error">
<strong>FINALIZING CANNOT COMPLETE</strong><br>
[iterate: $errors, (var('theErr'))]
['You must select at least one rating from Group ' + $theErr + '.<br>']
[/iterate]
</div>
This seems to work fine until there is ONE error. The conditional would be false and not show the error. So I added an equals sign:
[if(var('errors')->Size >= 1)]
<div class="alert alert-error">
<strong>FINALIZING CANNOT COMPLETE</strong><br>
[iterate: $errors, (var('theErr'))]
['You must select at least one rating from Group ' + $theErr + '.<br>']
[/iterate]
</div>
However, now when there are NO errors, it still shows the DIV presumably because the value of $errors is still 1.
I'm confused and not sure what to do.
Patrick Larkin
Information Systems
Bethlehem Area School District
https://www.beth.k12.pa.us
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>