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.

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



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


30.0k

hi, What is in

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



5.7k

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