Class autoloading not working – after adding new class into nette/forms:^3.1.9-RC

m.brecher
Generous Backer | 758
+
0
-

Hi everybody !

I wish a happy New Year and sorry for disturbing your holiday, but I have a problem:

I have done little testing of nette/forms:^3.1.9-RC and found some little cases where small improving may be useful. To make some necessary testing I have created new class of new form input control for date directly in directory of nette forms. The autoloading of this new class doesn´t work, but it was possible to fix it with include. See the extract of the code below:

namespace Nette\Forms;
.....
class Container extends Nette\ComponentModel\Container implements \ArrayAccess
{
.......
    public function addDate(.....): Controls\DateInput		// added new method - works ok
    {
        include __DIR__.'/Controls/DateInput.php';       /* fix of not-working autoloading  */
        return $this[$name] = (new Controls\DateInput($label))  ..... ;
    }
}

new added class in \vendor\nette\forms\src\Forms\Controls\DateInput.php

namespace Nette\Forms\Controls;
......
class DateInput extends TextInput
{
........
}

I expect, that it is simply not possible to modify the source code of Nette in such straightforward way. Could somebody advice me the correct procedure ?

Thanks

mystik
Member | 291
+
0
-

Did you dumped updated autoloader of composer by calling composer dump-autoload? If not composer do not know new class is added somewhere in vendor and uses cached autoloader where it is not registered.

mystik
Member | 291
+
0
-

Btw if you want DateTimeInput you can check this https://github.com/…ols/DateTime

m.brecher
Generous Backer | 758
+
0
-

@mystik

Did you dumped updated autoloader of composer by calling composer dump-autoload?

Yes this is the reason, no composer autoload dump, thank You for comment.

m.brecher
Generous Backer | 758
+
0
-

@mystik

Btw if you want DateTimeInput you can check this https://github.com/…ols/DateTime

Thanks for this advice, I see some imperfections in the current set of form inputs, I will try.