按翻译标签对表单字段选择进行排序

时间:2015-08-26 13:26:30

标签: symfony symfony-forms

我有一个数组:

<%@include file = "globalFunctions.jsp" %> <% Boolean submitted = Boolean.parseBoolean(request.getParameter("isSubmitted")); double we = 0, he = 0; if(submitted){ weight = Double.parseDouble(request.getParameter("w")); height = Double.parseDouble(request.getParameter("h")); } %> <h3>BMI Calculator</h3> <form action = "index.jsp" method = "post"> <input type ="hidden" name = "isSubmitted" value = "true"> Weight: <input type = "text" name = "w"> <br> <br> Height: <input type = "text" name = "h"> <br> <br> <input type = "submit" value = "Compute"> <br> <br> BMI: <%= calcBMI(we, he) %> <br> <br> Classification: <%= classification %> </form>

我指定为用于字段创建的[ 0 => 'translate.label1', 1 => 'translate.label2', 2 => 'translate.label1' ] 参数。

现在,是否可以通过已翻译的标签对这些选项进行排序?例如,choices已翻译的值label1 - 某些内容label2 - abracadabra 。当然,我希望选择的选项是:

  • 胡言乱语
  • 东西

我想使用这种方法:https://stackoverflow.com/a/21586886/2324004

但它是否涉及视图内的第二个翻译摘要?有任何想法吗?我宁愿使用更灵活的东西,因为我的表单基于非固定的选择计数,它会执行递归的东西......

1 个答案:

答案 0 :(得分:0)

您必须在上传数据后在js中执行此操作。

检查此主题:

Javascript to sort contents of select element