TYPO3:读取TCA“类型"的值. '检查'(位掩码) [英] TYPO3: Reading the values of a TCA 'type' => 'check' (bitmask)

查看:94
本文介绍了TYPO3:读取TCA“类型"的值. '检查'(位掩码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在前端的事件中显示选择的日期:

I need to show a selection of days in an event in the frontend:

在我的TCA中,我将字段设置如下:

in my TCA I set the field like this:

'days' => [
    'exclude' => true,
    'label' => 'choose weekdays',
    'config' => [
        'type' => 'check',
        'eval' => 'required,unique',
        'items' => [
            ['monday',''],
            ['thuesday',''],
            ['wednesday',''],
            ['thursday',''],
            ['friday',''],
            ['saturday',''],
            ['sunday',''],
        ],
        'cols' => 'inline',
    ],
],

那在数据库中存储了一个整数,但是现在我必须在前端的流体模板中显示选定的日期.

That stores an integer in the db, but now I have to display the selected days in a fluid template in the frontend.

这是 TYPO3文档中的参考这说明我应该检查值的bit-0 ...我进行了很多搜索,但除了此

This is the reference regarding in the TYPO3 documentation which explains that I should check the bit-0 of values ... I've searched a lot but couldn't find anything except this question here on stack overflow, which I cannot get to work.

推荐答案

我强烈建议不要使用check字段的位掩码功能.重新分配值的开销很少值得花费,对于大多数开发人员来说也很难理解.

I strongly recommend not to use the bitmasking feature of the check field. It's rarely worth the overhead to split the values apart again and also is a lot harder to understand for most developers.

您可以使用select字段,在这种情况下, selectCheckBox 应该可以很好地为您服务.给定items的静态列表,您将获得带有所选值的CSV字符串,该字符串更容易拆分,例如在Extbase域模型的getter方法中.如果可以的话,您甚至可以使用与记录的关系,它甚至更干净,但需要额外的工作.

Instead you can use a select field, in this case selectCheckBox should serve you well. Given a static list of items you will get a CSV string with the selected values which is a lot easier to split, e.g. in a getter method of an Extbase domain model. If it makes sense you can even use a relation to records instead which is even cleaner but requires additional work.

如果您仍然想继续使用位掩码,请此答案可能会对您有所帮助.

If you still want to continue with bitmasks this answer may help you.

这篇关于TYPO3:读取TCA“类型"的值. '检查'(位掩码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆