Use of same form in several presenters – Form class not found

Notice: This thread is very old.
coyot_
Member | 12
+
0
-

Hello,

I'm trying to use one form class in several presenters. I've followed this guide: Use of same form in several presenters [CZ only]

I've created app/forms folder and put in my form class (called GameForm in GameForm.php file).

Its content (inspired by example on page from link above):

use Nette\Application\UI,
    Nette\ComponentModel\IContainer;

class GameForm extends UI\Form
{
    public function __construct(IContainer $parent = NULL, $name = NULL)
    {
        parent::__construct($parent, $name);
		$form->addText('name', 'Název hry:');
		$form->addTextarea('description', 'Popis hry:');
		$form->addUpload('image', 'Obrázek:');
		$form->addSubmit('login', 'Uložit');
    }
}

In my presenter I call $form = new GameForm();.

I'm getting error: “Class ‘GameForm’ not found”.

I tried to delete temp folder content and it didn't help.

Does anyone know, where could be the problem?
Could anyone provide me working example?

Last edited by coyot_ (2013-11-22 03:11)

Šaman
Member | 2466
+
0
-

What about namespaces? Are that ok? (You use GameForm without any NS?)

coyot_
Member | 12
+
0
-

Yes, in my presenter I only call $form = new GameForm(); … So, I use GameForm without any NS.

I thought, that if my class is sub-directory of app directory (app/forms), it would be autoloaded.

coyot_
Member | 12
+
0
-

[SOLVED]

I finally found out, what the problem is.

I forgot to put php open tag at the start of my php file.

Shit happens