Search code examples
typo3typoscriptfluidtypo3-extensionstx-mask

How to render a Mask checkbox with Typo3 Fluid?


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!


Solution

  • 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).