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

my forms not showing in my view

i have foms folder, inside forms folder i have SendNewsLetter.php that contains the ff. code

<?php
use Phalcon\Forms\Form,
    Phalcon\Forms\Element\Submit,
    Phalcon\Validation\Validator\PresenceOf,
    Phalcon\Validation\Validator\Email,
    Phalcon\Validation\Validator\Identical,
    Phalcon\Validation\Validator\StringLength;

class SendNewsLetter extends Form(){

    public function initialize(){
        $this->add('email', new PresenceOf(array(
            'message' => 'The e-mail is required'
        )));

        $this->add('email', new Email(array(
            'message' => 'The e-mail is not valid'
        )));

        $this->add(submitButton(array("Subscribe Now", "class" => "btn btn-success")));
        echo"hahaha";
    } 
}

in my loaders i have this code

$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->modelsDir,
        $config->application->formDir
    )
)->register();

in my view

{{  SendNewsLetter() }}

but it shows this error

Notice: Undefined offset: formDir in C:\Users\spilagan20140973\Desktop\BOOTSTRAP FILES\PORTABLES\USBWebserver v8.6\root\PHALCON\app\config\loader.php on line 12
Undefined function 'SendNewsLetter' in C:\Users\spilagan20140973\Desktop\BOOTSTRAP FILES\PORTABLES\USBWebserver v8.6\root\PHALCON\app\config/../../app/views/index/index.volt on line 203

You can take a look on my code, tnaks in advance.

https://github.com/stevenpilagan/phalconrepo.git



98.9k
Accepted
answer

It means: $config->application->formDir is not defined, it says "formDir" instead of "formsDir"

https://github.com/stevenpilagan/phalconrepo/blob/master/app/config/config.php#L17

tnks to a lot.

another error appearing

Undefined function 'SendNewsLetter' in C:\Users\spilagan20140973\Desktop\BOOTSTRAP FILES\PORTABLES\USBWebserver v8.6\root\PHALCON\app\config/../../app/views/index/index.volt on line 201


43.9k

hi, What is in

/app/views/index/index.volt on line 201



16.3k

Hi,

I have the same issue. I used the same code as @Steven just to test creating and calling a new class but I get "Undefined function 'SendNewsLetter'. How can I get a custom form (class) to work in a view.

Amal