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

Danger setValue #114

Closed
nechutny opened this issue Mar 6, 2016 · 3 comments
Closed

Danger setValue #114

nechutny opened this issue Mar 6, 2016 · 3 comments

Comments

@nechutny
Copy link

nechutny commented Mar 6, 2016

Hello,

before some time I've been fixing a bug in our project which was caused by using setValue on input instead of setDefaultValue, so typed value by user was overwritten. After investigation I've found same bug across our projects and made by a lot of different developers.
This moved me to think about setValue method which is confusing. Is there any use-case, when it can't be protected? I think, that it's only used in creating custom inputs and then protected or at least @internal annotation should help with eliminating this mistake. Custom inputs are extending input so protected is ok.
In my opinion is this more confusing, than eg. method callbacks so we should think about it.

@dg
Copy link
Member

dg commented Apr 1, 2016

setValue() cannot be protected, because is called from Container, Rules and Validator.

dg added a commit to dg/nette-forms that referenced this issue Jun 30, 2016
dg added a commit to dg/nette-forms that referenced this issue Jun 30, 2016
@dg dg closed this as completed in 42a8f01 Jun 30, 2016
dg added a commit to dg/nette-forms that referenced this issue Jun 30, 2016
dg added a commit to dg/nette-forms that referenced this issue Jan 16, 2017
dg added a commit to dg/nette-forms that referenced this issue Jun 19, 2017
dg added a commit to dg/nette-forms that referenced this issue Mar 11, 2018
@MartinMystikJonas
Copy link

MartinMystikJonas commented Apr 6, 2022

is only reason why setValue is marked internal to prevent this accidental error? We have use case where we needs to overwrite user values (user press button and it needs to replace previous values) and I am not sure if we should just ignore internal annotation or if there is another way to solve this.

@dg
Copy link
Member

dg commented Apr 8, 2022

Yes, it's only for that reason.

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

3 participants