Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with BaseControlTrait in my class extending Nette\Forms\Controls\TextInput #7

Closed
mprof opened this issue Feb 6, 2022 · 3 comments

Comments

@mprof
Copy link

mprof commented Feb 6, 2022

When using Nextras\FormComponents\Fragments\Traits\BaseControlTrait in my class representing live form server validation, then occours error with method getControl() (origin in BaseControlTrait):

TypeError: Nette\Forms\Helpers::exportRules(): Argument #1 ($rules) must be of type Nette\Forms\Rules, null given

Seems like $this->rules variable is empty, when using this trait.

1269EAA2E1FC4D97BA1BA55DCB3F2DF3

@hrach
Copy link
Member

hrach commented Feb 6, 2022

What is the namespace of the TextInput you inherit from? Since if you are using https://github.com/nextras/form-components/blob/master/src/Fragments/UIControl/TextInput.php you shouldn't use traits.

@mprof
Copy link
Author

mprof commented Feb 6, 2022

What is the namespace of the TextInput you inherit from? Since if you are using https://github.com/nextras/form-components/blob/master/src/Fragments/UIControl/TextInput.php you shouldn't use traits.

Namespace of inherited TextInput is: Nette\Forms\Controls (like in your solution)

I am trying to reproduce your solution posobota-2014-server-validation in actual version of Nette, so everything is almost same, but when use BaseControlTrait, described error occurs.

@hrach
Copy link
Member

hrach commented Feb 7, 2022

well, that's 8 years old. things changed since then. you may take a look at
https://github.com/nextras/form-components/blob/master/src/Controls/AutocompleteControl.php
how to inherit from text field.

@mprof mprof closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants