【问题标题】:Disable selected option in f:form.select禁用 f:form.select 中的选定选项
【发布时间】:2018-09-13 10:44:15
【问题描述】:

我想使用<f:form.select> 来显示地址类型列表。但我也想禁用一些选项。我该如何禁用它?效果应该是这样的:

我当前的代码是这样的(完全工作,但没有禁用选项):

<f:form.select class="form-control"
    property="type"
    options="{addressType}"
    optionLabelField="title"
    prependOptionValue="0"
    prependOptionLabel="Please select"/>

我尝试阅读文档并检查谷歌,但这里什么都没有。我可以用&lt;option value="any" disabled&gt; 做到这一点,但这不是解决方案,因为我使用&lt;f:form action(...)&gt; 并且我使用这个对象

在这种情况下我该怎么办?

【问题讨论】:

    标签: typo3 fluid typo3-7.6.x


    【解决方案1】:

    f:form.select 内的循环内使用f:form.select.option 手动呈现您的选项,然后使用additionalAttributes 添加disabled="disabled" 属性。请注意,传递additionalAttributes="{disabled: valueMaybeNull}" 无论如何都会呈现该属性,这意味着您需要围绕整个f:form.select.option 设置一个条件,以便在禁用时呈现一种方式,在激活时呈现另一种方式。

    https://viewhelpers.fluidtypo3.org/typo3/cms-fluid/8.7.17/Form/Select/Option.html

    【讨论】:

    • 看起来很酷,我检查一下。谢谢,我没有找到这个,因为我在typo3.7上工作,但无论如何,我们很快将我们的错字更新到v.8,我可以使用你的解决方案。
    猜你喜欢
    • 2020-07-03
    • 1970-01-01
    • 1970-01-01
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 2015-07-03
    相关资源
    最近更新 更多