问题描述
我需要在前端的事件中显示选择的日期:
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 ...我进行了很多搜索,但除了此在堆栈溢出时出现,我无法正常工作.
推荐答案
我强烈建议不要使用check
字段的位掩码功能.重新分配值的开销很少值得花费,对于大多数开发人员来说也很难理解.
您可以使用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“类型"的值. '检查'(位掩码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!