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

Forms: Default values behaviour with disabled fields #961

Closed
enumag opened this issue Feb 7, 2013 · 12 comments
Closed

Forms: Default values behaviour with disabled fields #961

enumag opened this issue Feb 7, 2013 · 12 comments

Comments

@enumag
Copy link
Contributor

enumag commented Feb 7, 2013

In my opinion BaseControl::setDefaultValue() and Container::setDefaults should set value to disabled field even if the form was submitted. The disabled field is empty after error with current behaviour.

I'd like to hear your opinions first. I'll prepare PR if this idea gets some support.

@Elijen
Copy link
Contributor

Elijen commented Feb 21, 2013

Can't you use setValue() on disabled fields instead?

@enumag
Copy link
Contributor Author

enumag commented Feb 21, 2013

Sure but I can't use just one setDefaults call, I need to use setValue(s) separately. Appareantly nobody cares. Closing.

@enumag enumag closed this as completed Feb 21, 2013
@vojtech-dobes
Copy link
Contributor

Don't close it, I believe it's valid request.

@Majkl578
Copy link
Contributor

Not sure what it'd be good for, but at least it makes sense.
👍

@fprochazka
Copy link
Contributor

@Majkl578 the use case is in description. And I agree.

@fprochazka
Copy link
Contributor

@enumag Oh, and by the way, 14 days of nobody responding means nobody has time to think about it/implement it. If we wouldn't like it, you would hears us wery clearly.

@enumag
Copy link
Contributor Author

enumag commented Feb 21, 2013

OK, reopening. :-D

@enumag enumag reopened this Feb 21, 2013
@Elijen
Copy link
Contributor

Elijen commented Feb 21, 2013

Wouldn't be better solution implementing read-only functionality rather than changing behaviour of forms?

Also, at this point, when you use setDefault() you know that user can change the value, when you use setValue() he can't. If you implement the disabled functionality it wouldn't be so straightforward.

@hrach
Copy link
Contributor

hrach commented Feb 21, 2013

Well, both sides have some pros and cons.

enumag

  • easy of use, you just fetch data, and give them to form. Fields, which user can't change, are marked as disabled.
  • lightweight and secure solution. read-only wouldn't be sufficient, because it can be changed by js, etc.

Elijen

  • you are right, it wouldn't be so straightforward, but, if you imagine just the "outside" API, it's quite logical. You pass the default value and forbid some values to change. As a result, you get "default values + user change", you don't care that user can't change sth.
  • meaning of setValue is imo quite different. It just sets values for this request. You are not right, that user can't change value, which is defined by setValue. It depends on the time when you set it. For example in render method it's late.

If I should choose, I would change it as @enumag suggest.

@dg
Copy link
Member

dg commented Apr 7, 2013

In what cases are you using disabled controls?

@enumag
Copy link
Contributor Author

enumag commented Apr 12, 2013

I use it in form for editation of a user. User himself can't change his username but admin can. I could remove the field entirely but I like disabled field more in this case.

@dg dg closed this as completed in 1e36069 Apr 15, 2013
dg added a commit that referenced this issue May 2, 2013
… (BC break) [Closes #981] [Closes #961]"

This reverts commit 1e36069.
@dg
Copy link
Member

dg commented May 2, 2013

Has been reverted (70cd9d4) it causes some problems http://forum.nette.org/cs/14337-neocekavane-chovani-setdefaults#p103106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants