[TYPO3] globalvars, GP and checkbox arrays

Claudio Strizzolo claudio.strizzolo at ts.nogarb.ageinfn.it
Thu Mar 27 11:39:25 CET 2008


Hi all,
Maybe a stupid question, but I couldn't find an answer in the 
documentation (TSref and such).
I need to set up a condition in TS, depending on a value assigned to a 
field which is supplied through a form. Normally this would work:

[globalString = GP:Vehicle=car]
  (...)
[global]

Unfortunately, the field in the form is actually an array filled with 
data supplied through checkboxes:

<input type="checkbox" name="Vehicle[]" id="Vehicle_train" value="train" /
>Train
<input type="checkbox" name="Vehicle[]" id="Vehicle_car" value="car" />Car
<input type="checkbox" name="Vehicle[]" id="Vehicle_bus" value="bus" />Bus

In this case I don't know how to check for such a value. I tried with:

[globalString = GP:Vehicle=car]

but this obviously doesn't work because Vehicle is not a string.
I can't even check using array indexes, because I do not know which 
elements of the array have been filled:

[globalString = GP:Vehicle|0=car]

"car" might be at position 0 in the array if "train" was checked too, or 
"1" if it were the first option to be selected, so I can't know which 
field must be checked. And I have a large number of possible checkboxes, 
then I wouldn't like using a dirty OR format like:

[globalString = GP:Vehicle|0=car][globalString = GP:Vehicle|1=car]
[globalString = GP:Vehicle|2=car] (...)

I can't replace the checkboxes with radio or such too, because more than 
one field can be checked at the same time.
Any hints?
Thanks in advance

Claudio


More information about the TYPO3-english mailing list