Deleting a 0 in numeric field doesn't cause in-line editor to update
Deleting a 0 in numeric field doesn't cause in-line editor to update
I have an inline editor set up with multiple numeric fields. If the record starts with a 0 in a field and I delete the 0 (wanting to make it null), there is not an update. If I update the field to something other than 0, like 1, then delete the 1 , the field will become a null. Here is the field setting:
Field::inst( 'am_wx.curwindspd' )
->setFormatter( Format::ifEmpty( null ) )
If the field starts as something other than 0, I clear it out and can see that the PHP server script is called to update and the field stays as a null. If the field starts as 0, I clear it out, and the PHP server script is never called.
I'm sorry I can't post to a test example right now.
Thanks in advance.
This question has accepted answers - jump to:
Answers
Hi,
I've just tried to reproduce the issue in this example. What I did was:
0
I'm wondering if you might have a Javascript check somewhere that is blocking the submit? I think I would need a test case showing the issue to be able to help resolve this one I'm afraid.
Allan
Thanks for looking at this. I'll explore further and try to get a test case posted soon.
Alan,
I've tried to put in some breaks in editor to see if I can figure anything out. Changing a 0 to blank , when it gets to deepCompare, console shows:
and
and
So it never triggers the edit event.
I am using version 2.0.5 installed from webpack.
Interesting - thanks for digging into that.
I'm trying to think about how I can reproduce that locally. Can you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is. That will let me see the data you are using.
Thanks,
Allan
I am getting an error on the debugger. This is a webpack build and normally jquery is in the build js file, so I had to include jQuery again so that debugger would run (if that makes sense).
and
I am suspicious that I have numeric values in my json and it is comparing a numeric 0 to blank string and coming out equal. An example is curwindspd in the data that has a 0 but should be blanked out. Here is some sample json data i use:
Thanks.
Ah - yes, I think you are right. I need to have a little thing about that. We can't use strict typing there, because when a
number
value is put aninput
element and then read back, it will come back as a string. Possibly I need to add some extra checks for specific falsy cases in there. Many thanks for the data and insight - I'll get back to you on Monday about this.Allan
Thanks so much!
Any chance you've had a chance to look at this? I am not quite sure how to know if this is still an active issue. Thanks.
Apologies - yes, this is still active - I haven't had a chance yet to dig into this. Will try to make sure I do so tomorrow and get back to you.
Allan
I've been thinking about this a bit more and I think
fields.getFormatter
is going to be the solution - e.g. add this to the field type that is causing problems because it is being converted to a string:That will convert the string value to a
number
whenever the value is read.Regards,
Allan
Hi,
Thanks for looking at this, but It doesn't seem to be fixing the problem. The json ajax data is a numeric, so converting to a value doesn't change it. However, I did try this:
and it seems to work. Would that make sense to you?
Yes - that makes sense. It is basically approaching it from the other side. I'm surprised the client-side formatter didn't do the job though - I will look into that. Thanks!
Allan