连接 form_row(form.value)

Concatenate form_row(form.value)

在带有 Symfony 的 Twig 中,是否可以将表单中的多个值连接成一行。 就像我在表单字段中选择一个值,然后我希望这个值出现在同一个表单的另一个字段中,以便将它与新字段的值连接起来。

                        <div class="row">
                            <div class="col-md-6">
                                {{ form_row(form.EPCode) }}
                                {{ dump(form) }}
                            </div>
                            <div class="col-md-6">
                                {{ form_row(form.NC8Id) }}
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                {{ form_row(form.EcoModulation) }}
                            </div>
                            <div class="col-md-6">
                                {{ form_row(form.date) }}
                            </div>
                        </div>

我想将 {{ form_row(form.EcoModulation) }} 值放入 {{ form_row(form.EPCode) }}。 感谢您的回答

如果你只想在 twig 中连接多个变量,你可以像

{{variable1 ~ variable2}}

所以 '~' 运算符连接 2 个值..如果这是你想要的..但​​是如果你希望值在客户端根据某些选择或字段动态变化,那么你需要 javascript为此。