简体   繁体   English

如何使用Typo3 Fluid渲染“蒙版”复选框?

[英]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. 我使用Typo3的Mask创建了一个content元素,编辑者可以在其中选择提供的付款选项。 In the fluid template however, an integer with a bitmask is returned and not each individual option. 但是,在流体模板中,将返回带有位掩码的整数,而不是每个单独的选项。

带遮罩内容元素的付款选项选择

The default rendering suggested by mask is: mask建议的默认渲染为:

{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). data.tx_mask_ue_payment_accepted的结果可以从0(什么都没有选择)到511(所有9个选项都选择)之间变化。 Has anyone managed to smoothly implement the checkbox with a for-loop or anything proper and if so how? 有没有人设法通过for循环或任何适当的方法顺利实现复选框,如果可以的话,怎么做?

Many thanks in advance! 提前谢谢了!

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. 对于当前的FE插件,我在几个区域中使用了位掩码,没有找到比在显示表单之前在控制器操作中映射字段-值对更好的方法了。

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). 我将这些值绑定到数组,并将其作为复选框在流体循环中显示(不使用extbase直接属性映射)。

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". 如果值存在,我们将复选框设置为“选中”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM