douhuanglou1445 2012-06-23 21:37
浏览 59
已采纳

Symfony 2:在表单构建器中使用Twig扩展

I need to change the way a value or label is formatted with a custom filter. However, I need to do this from the form builder rather than in the twig template itself. In other words, when I build my form in the abstract type class, I need to be able to apply specific formatting.

Here is one application where this is needed:

Labels assigned to form elements are based on the database table field names. I need to be able to change how those labels are rendered, such as title case, or upper case, etc.

What's the best way of doing this?

Thanks!

  • 写回答

1条回答 默认 最新

  • drvkf88226 2012-06-24 05:18
    关注

    You can create a custom form field type, that extend from choice or entity field type. Then you can customize the template for the field applying filters or whatever you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动