Symfony2: deprecated get in FormView replacement?(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 替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Symfony2:不推荐使用 FormView 替换?


- Laravel 仓库 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01