Symfony2:不推荐使用 FormView 替换? [英] Symfony2: deprecated get in FormView replacement?

查看:24
本文介绍了Symfony2:不推荐使用 FormView 替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在版本中

2.3、属性

In versions < 2.3, the attribute

data-prototype="{% filter escape %}{% include 'ManaClientBundle:Member:member_prototype.html.twig' with {'form': form.members.get('prototype')} %}{% endfilter %}"

允许原型显示为一行单元格.当然,在 2.3 中,这一行会产生错误

allowed the prototype to display as a row of cells. In 2.3, of course, this line generates the error

对象SymfonyComponentFormFormView"的方法get"不存在

Method "get" for object "SymfonyComponentFormFormView" does not exist

根据 UPGRADE-2.1.md,不推荐使用 get.它不能被建议的 vars 替换,因为它会产生类似的错误.我怎样才能(容易?)像以前一样在 2.3 中渲染原型?使用

Per UPGRADE-2.1.md, get is deprecated. It cannot be replaced by the suggested vars as it produces a similar error. How can I (easily?) render the prototype as before in 2.3? Using

data-prototype="{{ form_widget(form.members.vars.prototype)|e }}"

无论 config.yml 中 twig:resources:form 的 div 或 table 设置如何,都没有提供有用的解决方案.

does not provide a useful solution regardless of div or table settings for twig:resources:form in config.yml.

<tr id="member-form">
<td><input class="smallform" type="radio" name="household[isHead]" value="__name__"></td>
<td>{{ form_widget(form.include, {'attr': {'class':'smallform'}}) }}</td>
<td>{{ form_widget(form.fname, {'attr': {'class':'smallform'}}) }}</td>
<td>{{ form_widget(form.sname, {'attr': {'class':'smallform'}}) }}</td>
<td>{{ form_widget(form.dob, {'attr': {'class':'smallform'}}) }}</td>
<td>{{ form_widget(form.sex, {'attr': {'class':'smallform'}}) }}</td>
<td>{{ form_widget(form.ethnicity, {'attr': {'class':'smallform'}}) }}</td>
<td><a id="removeTr" class="smallbutton" href="#" onclick="removeTr(this)">Remove</a>

推荐答案

form.members.get('prototype') 替换为 form.members.vars.prototype.

本可以更清楚地知道该怎么做,但找到解决方案的猴子比无限的少.

Could have been a whole lot clearer what to do, but fewer than infinite monkeys found a solution.

这篇关于Symfony2:不推荐使用 FormView 替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆