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

Trying to add forms

Hi,

This is my second question here and understand that I am a beginner in phalcon. I am trying to add a form on my application within the following folder : /app/forms/SubmitSubtitlesForm.php

Here is what I did so far :

In my controller :

use Subtitles\Forms\SubmitSubtitlesForm;

public function submitAction()
{
   $submitForm = new SubmitSubtitlesForm(null);
}

Also added forms dir in my config.php

'formsDir'       => APP_PATH . '/app/forms/',

and my form file :

<?php

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

class SubmitSubtitlesForm extends Form
{

    public function initialize()
    {

    }
}

Unfortunately I am getting the following error :

Fatal error: Class 'Subtitles\Forms\SubmitSubtitlesForm' not found in C:...\subtitles\app\controllers\SubtitlesController.php on line 37

Will appreciate some help.

Thanks!



852

Yes it is the name of my project, so far I have :

project name : subtitles controller : SubtitlesController.php

Loader setup is :

<?php

$loader = new \Phalcon\Loader();

/**
 * We're a registering a set of directories taken from the configuration file
 */
$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->formsDir,
        $config->application->modelsDir
    )
)->register();

Thanks for your help!