1

I've created a content element with Mask for Typo3 where the editor can select the payment options provided. In the fluid template however, an integer with a bitmask is returned and not each individual option.

Payment option selection with Mask content element

The default rendering suggested by mask is:

{f:if(condition: data.tx_mask_ue_payment_accepted, then: 'On', else: 'Off')}

The result of data.tx_mask_ue_payment_accepted can vary from 0 (nothing selected) to 511 (all 9 options selected). Has anyone managed to smoothly implement the checkbox with a for-loop or anything proper and if so how?

Many thanks in advance!

r4fx
  • 652
  • 5
  • 12
Jan
  • 163
  • 14

2 Answers2

0

I use bitmask in a couple of areas for my current FE plugin and haven't found a better way than to map the field-value-pairs in your controller action prior to displaying the form.

For this I implemented two methods which will convert the current bitmask value to individual boolean values (and vice versa). I bind those values to an array and display it in a fluid for loop as checkboxes (not using extbase direct property mapping).

taalas
  • 395
  • 3
  • 16
0

Maybe this gets somebody in the right direction, even if its no copy&paste ready solution. Fluid:

<input type="checkbox" name="tx_myext[checkbox][0]" value="1" id="checkbox0" class="checkbox" {f:if(condition:'{return.checkbox.0} == "1"',then:'checked="checked"',else:'')}>
<input type="checkbox" name="tx_myext[checkbox][1]" value="1" id="checkbox1" class="checkbox" {f:if(condition:'{return.checkbox.1} == "1"',then:'checked="checked"',else:'')}>

As you can see we get an array "return" back that contains the values from the transmitted form. If the values exists we set the checkbox to "checked".

mycaravam
  • 127
  • 5