phalconvolt

Phalcon Volt adding variable name to input


Ok so this is my code:

{%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 %}

It works fine on the label but inside the text_area function, it is just displaying language.getLanguage() as text and not echoing the value of it. Is there a way to escape out of that function that displays the input to echo the language name?


Solution

  • The {{ }} is like doing an echo. So in your example you are doing echo echo :)

    Try like this:

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

    Just a tip: not sure what you are doing inside the language.getLanguage() method, but you are calling it 3 times. This leads to unnecessary operations, this can be a huge problem, especially in cases of DB Queries inside the method. Just assign it to a variable.

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