【问题标题】:Phalcon Volt adding variable name to inputPhalcon Volt 将变量名称添加到输入
【发布时间】:2018-03-17 12:58:28
【问题描述】:

好的,这是我的代码:

{%for language in languages %}
    <div class="form-group">
        <label for="{{ language.getLanguage() }}">{{ language.getLanguage() }}</label>
        {{ text_area('{{ language.getLanguage() }}', 'size' : 30, 'class' : 'form-control form-filter input-sm') }}
    </div>
{% endfor %}

它在标签上工作正常,但在 text_area 函数内,它只是将language.getLanguage() 显示为文本,而不是回显它的值。有没有办法摆脱显示输入以回显语言名称的函数?

【问题讨论】:

    标签: phalcon volt


    【解决方案1】:

    {{ }} 就像在做一个echo。因此,在您的示例中,您正在执行 echo echo :)

    试试这样:

    {{ text_area(language.getLanguage(), 'size' : 30, 'class' : 'form-control form-filter input-sm') }}
    

    提示:不确定您在 language.getLanguage() 方法中做了什么,但您调用了 3 次。这会导致不必要的操作,这可能是一个巨大的问题,尤其是在方法内部的 DB 查询的情况下。 只需将其分配给变量即可。

    {% set lang = language.getLanguage() %}
    

    【讨论】:

      猜你喜欢
      • 2013-04-28
      • 2013-09-11
      • 1970-01-01
      • 2013-01-13
      • 2018-11-26
      • 2016-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多