Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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


64.1k
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



65.8k
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.phalconphp.com/en/latest/api/Phalcon_Forms_Element.html