在模板的蓝图文件中,我想使用转发器/列表字段,
有一个带有选项的选择字段,
和条件字段评估用户选择的选项以相应地显示字段。
我想在长文章中使用它,用户可以在其中添加/切换不同类型的组件
如何将条件设置为选择字段的值(重复)?
就像现在的代码一样,只有选择是可见的,条件不起作用。
header.field.selection:
type: list
style: vertical
label: Repeater/list with conditional field selection
fields:
.select: # this select sets the boolean for the conditional fields
type: select
size: long
classes: fancy
label: Select the type of field you would like to add
options:
tinymce: Textarea
slideshow: Slideshow
testimonial: Testimonial
video: Video
.tinymce:
type: conditional # if Textarea was selected render the tinymce fields
condition: "header.field.selection.select is same as('tinymce') ? 'true' : 'false'"
fields:
.fieldName:
type: text
label: Tinymce
.slideshow:
type: conditional # if slideshow was selected render the slideshow fields
condition: "header.field.selection.select is same as('slideshow') ? 'true' : 'false'"
fields:
.fieldName2:
type: text
label: Slideshow
.testimonial:
type: conditional # if testimonial was selected render the testimonial fields
condition: "header.field.selection.select is same as('testimonial') ? 'true' : 'false'"
fields:
.fieldName3:
type: text
label: Testimonial
.video:
type: conditional # if video was selected render the video fields
condition: "header.field.selection.select is same as('video') ? 'true' : 'false'"
fields:
.fieldName4:
type: text
label: Video
条件字段不是基于其他字段“实时”工作的东西,它只是可以在服务时执行 PHP 函数并做出决定。 其他任何事情都需要 Javascript 才能运行。
很想在 Form 插件中看到这样的核心字段 :) PR 也许??
@rhukster
已为分支“功能/灵活表单字段”发出拉取请求。
地位:
我确实需要一些帮助:
tnx
(我在 slack 频道上是 'genenenenaam')
@rhukster
对“列表项的排序”和字段模板“list.html.twig”的名称有一些依赖性吗?
我做了一个测试,它似乎:
我相信这个问题的答案可以解决我与新功能当前状态的问题。