We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to do comparisons in volt

below is my code .....and it is not working properly......error is shown in comments

{% for element in form %}
  {% if is_a(element, 'Phalcon\Forms\Element\Hidden') %}
    {{ element }}
  {% else %}
<div class="form-group">

{% if element.label() =="name" %}//Comparision is made here but not working
{{4}}
{% endif %}


85.5k
edited Oct '16

probably you wanted to do


{% if element.label == "name" %}

without the (). Never used those so i am not 100% sure what is the currect property/ method you need

nope....even this is not working

probably you wanted to do


{% if element.label == "name" %}

without the (). Never used those so i am not 100% sure what is the currect property/ method you need



93.7k
Accepted
answer
edited Oct '16

You are probably looking for element.getName(), this will return the <input name="first_name"/> attribute.

Full list of form element methods here: https://docs.phalcon.io/en/latest/api/Phalcon_Forms_Element.html