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
Show default Invoice/Quote item qty will be saved if empty #347
Show default Invoice/Quote item qty will be saved if empty #347
Conversation
Thank you for this change @thicolares. Unfortunately, I don't think it solves the issue completely. On a new invoice, if you don't add any qty, but you type an amount, then the totals don't get updated. So even though there is a I did some digging, and the below patch would fix the issue. diff --git a/src/CoreBundle/Resources/public/js/billing/view/item_row.js b/src/CoreBundle/Resources/public/js/billing/view/item_row.js
index 7544dce8..767fe9db 100644
--- a/src/CoreBundle/Resources/public/js/billing/view/item_row.js
+++ b/src/CoreBundle/Resources/public/js/billing/view/item_row.js
@@ -21,7 +21,7 @@ export default ItemView.extend({
this.model.collection.remove(this.model);
},
- async initialize () {
+ async onRender () {
await this.setModel();
await this.calcPrice();
}, There is already some code to set the default value to |
@pierredup you're right. I dig a bit the JS layer, but it was not clear. I'll apply this patch and test. But still, we could keep the placeholder, because this is what happens when we leave the input empty. |
The JS will populate the value to |
Exactly, I'm aware of that. I mean: that's a way to communicate the fallback: "hey, if you clear this, I'll still save it as 1" -- and that's how it behaves. Ironically because users tend to believe placeholders are default (pre-filled) values 😄 : https://www.uxmatters.com/mt/archives/2010/03/dont-put-hints-inside-text-boxes-in-web-forms.php (old, but gold) |
@pierredup I have tested too and it works as expected. Thanks for this tip! |
@pierredup, oh you're right. I had tested that at the beginning of my investigation with the old version |
- Patch suggested by pierredup
c260eda
to
4421467
Compare
Thank you @thicolares! |
Context
The bug reported in #303 is reproducible on version
2.0.4
-- run via this image tag.But I cannot reproduce on version
2.1.0-dev
: it doesn't override the Invoice Item Qty to 1 on the Edit form.However, it doesn't show the default value anymore.
Probably reason for the bug reported on #303:
The data option always overrides the value taken from the domain data (object) when rendering. This means the object value is also overridden when the form edits an already persisted object, causing it to lose its persisted value when the form is submitted. See more: https://symfony.com/doc/4.4/reference/forms/types/form.html#data
The previous fix:
That's the value in case the input is empty BUT we don't show the default value on the form. See more: https://symfony.com/doc/4.4/reference/forms/types/form.html#empty-data
This PR:
Create an invoice (same for Quote):
Edit invoice (same for Quote):