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
Added value_template_string property to BaseInput #961
base: main
Are you sure you want to change the base?
Added value_template_string property to BaseInput #961
Conversation
Codecov Report
@@ Coverage Diff @@
## master #961 +/- ##
=======================================
Coverage 95.62% 95.62%
=======================================
Files 24 24
Lines 2768 2768
Branches 244 244
=======================================
Hits 2647 2647
Misses 79 79
Partials 42 42
Continue to review full report at Codecov.
|
Hi @monim67 - thanks for looking into this! Do you think we should have a small regression test? |
@smithdc1 how can we do that? So far the tests run successfully so and I have checked the input renders properly after this change. Do you have anything on mind? |
To prevent the loss of original value passed to BaseInput sub-classes due to overwrite in render method, the value is stored into value_template_string property.
9f60ec0
to
f396c20
Compare
The heroku app is intended to demonstrate the bug, it does not include the fix. And the button labels don't change language. You might be seeing a cached version there. |
Traditionally we've said that if you need translation then you must instantiate your layout objects in a per-request context, such as a form's Making the values properly translatable would be a reasonable addition I think. But it would be a new feature, and I think we should make sure we've thought it through fully before just sneaking it in. (Including tests, and documenting any new attributes.) c.f. #776 here, which looked at the same issue. (Not sure if the approach was sound or not as yet.) An alternate approach I was pondering whilst thinking about this, but haven't thought through, is finding a way of not needing to overwrite value each time through render... (From the second pass it's a noop — can we lazily evaluate it somehow? — Not sure as yet.) |
@carltongibson while looking into it the lazy object also came to my mind, but if I assign a lazy object to The simple solution I thought was separating two value variables instead of overwriting, the one passed to the constructor We should really think deeper before we decide how to provide the feature. Haul me if I can be of any help 👍 |
Fixes:
What has been changed:
value_template_string
toBaseInput
class.How it fixes the issue:
The additional property
value_template_string
preserves the original value passed to sub-classesof
BaseInput
from being overwritten in therender
method.