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.

Form Phalcon

I have 2 steps for registration. In second step i want to keep all fields and values in hidden fields..and im using same form file for both. In my controler

 $form    = new RegisterForm(null, array("makehidden" => true);

in RegisterForm.php

if ($options['makehidden']) {
    $field_type =  "Hidden";
} else {
    $field_type =  "Text";
}

$uname =  new $field_type("uname");

but I'm getting error............ how to solve this?



84.5k
Accepted
answer

You have to use the classname plus its namespace:

if ($options['makehidden']) {
    $field_type =  'Phalcon\Forms\Element\Hidden';
} else {
    $field_type =  'Phalcon\Forms\Element\Text';
}

$uname =  new $field_type("uname");

http://php.net/manual/en/language.namespaces.importing.php