We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Help on forms

Hi All,

I have code below but showing me error:  Exception: Macro 'is_a' does not exist
Which part am i doing wrong or missing?

 * Edits a user based on its id
public function editAction($id)
    $collection = $this->collection;

    if (!$this->request->isPost()) {
        $criteria = array('_id' => new MongoId($id));           
        $users = $this->getCollection($collection, $criteria);

        if (!$users) {
            $this->flash->error("User was not found");
            return $this->forward("users/index");

        $users = (object) $users[0];

        $this->view->form = new RegisterForm($users, array('edit' => true));

Form <?php

use Phalcon\Forms\Form; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Element\Password; use Phalcon\Validation\Validator\PresenceOf; use Phalcon\Validation\Validator\Email; use Phalcon\Forms\Element\Hidden;

class RegisterForm extends Form {

public function initialize($entity = null, $options = null)
    if (!isset($options['edit'])) {
        $element = new Text("id");
    } else {
        $this->add(new Hidden("id"));            

    // Name
    $name = new Text('name');
    $name->setLabel('Your Full Name');
    $name->setFilters(array('striptags', 'string'));
        new PresenceOf(array(
            'message' => 'Name is required'

    // Name
    $name = new Text('username');
        new PresenceOf(array(
            'message' => 'Please enter your desired user name'

    // Email
    $email = new Text('email');
        new PresenceOf(array(
            'message' => 'E-mail is required'
        new Email(array(
            'message' => 'E-mail is not valid'

    // Password
    $password = new Password('password');
        new PresenceOf(array(
            'message' => 'Password is required'

    // Confirm Password
    $repeatPassword = new Password('repeatPassword');
    $repeatPassword->setLabel('Repeat Password');
        new PresenceOf(array(
            'message' => 'Confirmation password is required'




{{ form("products/save", 'role': 'form') }}

<ul class="pager">
    <li class="previous pull-left">
        {{ link_to("products", "&larr; Go Back") }}
    <li class="pull-right">
        {{ submit_button("Save", "class": "btn btn-success") }}

{{ content() }}

<h2>Edit user</h2>

    {% for element in form %}        
        {% if is_a(element, 'Phalcon\Forms\Element\Hidden') %}            
            {{ element }}
        {% else %}
            <div class="form-group">
                {{ element.label() }}
                {{ element.render(['class': 'form-control']) }}
        {% endif %}
    {% endfor %}



The problem is not with forms. The problem is that Volt does not recognize the IS_A function you are using.

Volt does not have all php functions built in. You can read here on how to extend votl: https://docs.phalcon.io/en/latest/reference/volt.html#extending-volt

And check Invo Demo where they add this function to volt: https://github.com/phalcon/invo/blob/master/app/config/services.php

thank you @nikolay

Can you mark thread as solved so others can use it?