【问题标题】:how to: specify multiple selected items in a multi-select element using typo3 fluid?如何:使用typo3流体在多选元素中指定多个选定项目?
【发布时间】:2014-02-07 18:42:33
【问题描述】:

在这样的流体代码中,我如何指定哪些项目是预选的?

<f:form.select name="coupon" options="{couponoptions}" multiple="true" size="10"/>   

couponoptions 是一个数组,其中定义了 uid 值和名称标签对,如下所示:

    $coupons = $this->couponRepository->findAll();

    foreach($coupons as $coupon) {
        $couponoptions[$coupon->getUid()] = $coupon->getName();

    }

选项都显示了,但我不知道如何指定哪些是预选的。

我正在使用typo3 v4.5.32 和流体1.3。

谢谢。

PS,预选项目在php中是这样找到的:

    $old = $this->couponsAttachedRepository->findAll();
    foreach($old as $o) {
        $c = $o->getCoupon();
        $couponsselected[$c->getUid()] = $c->getUid();
    }

PPS:如果我可以像 {optionsstring} 那样将选项作为字符串传递,我很乐意不使用 f:form.select 标记,但是当我尝试将标记更改为 html 实体时,例如我的

来自 lorenz 的回答:(我非常接近,我只需要像这样添加值)

 <f:form.select name="coupon" options="{couponoptions}" value="{couponsselected}" multiple="true" size="10"/>   

【问题讨论】:

    标签: html typo3 multi-select selected fluid


    【解决方案1】:

    可以使用value属性做一个预选,其中数组键就是值:

    PHP:

    $couponOptions = array('a' => 'Value A', 'b' => 'Value B');
    

    流体:

    <f:form.select name="coupon" options="{couponOptions}" multiple="true" value="a" size="10"/>
    

    【讨论】:

    • 谢谢,我的最终标签是
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-27
    • 2015-08-04
    • 1970-01-01
    • 1970-01-01
    • 2020-02-14
    • 1970-01-01
    相关资源
    最近更新 更多