Round of function not working
-
I have a form that performs calculations, and I’m using the round() function. Before the plugin update, it was working correctly. For example, when the value was 1,249.875, round() returned 1250. After the update, it now returns 1249 instead.
-
Also, how many decimal places does Forminator currently use in calculations? I can see that I’ve entered values with 4 decimal places, but it seems the calculation is only using up to 2 decimal places, which is causing different results.
Hi @mudassiriftikhar ,
I hope you’re doing well.
I’ve tried the round() feature, but it seems to be working properly on my end. Could you please export the form and share it with us using a service like pastebin?
If the form has sensitive info, feel free to duplicate the form and remove the sensitive info before exporting it.
You can see how to export it here – https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export
In case you always want to use the up value, you can also use ceil() – https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#calculations-operands-functions
how many decimal places does Forminator currently use in calculations? I can see that I’ve entered values with 4 decimal places, but it seems the calculation is only using up to 2 decimal places, which is causing different results.
You can define this in the calculation field settings – https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#calculation-settings
I hope to hear back from you soon.
Best Regards,
Williams ValerioThank you for your quick response.
You are correct that the round() function itself appears to be working properly. However, before the plugin update, my form calculations were producing the expected results, and after the update they are no longer behaving the same way.
My setup is as follows: I have a Select field with different calculation values assigned to each option, and then I use those values inside a Calculation field. The final result is wrapped in the round() function.
For example, if the user selects Option A, the Select field has a calculation value of 1.112, and the calculation formula is:
round({select} * 1125)
Before the update, this returned 1250. After the update, it now returns 1249.
The same issue happens with other options as well. For example, another option has a calculation value of 2.4525, and with the same formula:
round({select} * 1125)
it previously returned 2759, but now it returns 2756.
Even when I test the math separately, the normal calculation gives the expected result, but the form does not return the same value. Because of that, I suspect something has changed in how Forminator is handling decimal precision or select field calculation values after the update.
I’m not sure what is causing this, so I’d really appreciate your help in identifying the issue and fixing it. Thank you.
Hello @mudassiriftikhar ,
I hope you are doing well, and thank you for the update.
I tested the calculation that you mentioned on my lab site, and the results are correct. I couldn’t replicate the issue on my lab site. I suspect the issue could be specific to your form.
We will need to test the form that you are using. As mentioned previously, could you please export the form and share it with us using a service like pastebin?
If the form has sensitive info, feel free to duplicate the form and remove the sensitive info before exporting it.
You can see how to export it here – https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export
Kind Regards,
Fida Al HasanHello you can check here I’ve exported form https://pastebin.com/3Sd95bWP
Hi @mudassiriftikhar ,
I hope you’re doing well.
I’ve checked the form that you shared and confirmed the error. To check it further, this has been forwarded to the Forminator team, and we’ll update you here once we have further info.
Best Regards,
Williams ValerioHello @mudassiriftikhar
Hope you’re doing well today!
The Forminator team reviewed the form and confirmed that the behaviour of the round function is unexpected. This issue has been reported as a bug, and the Forminator team will investigate and fix it in the future release of the plugin. However, at the moment, I cannot provide an estimated time for when it will be fixed.
In the meantime, since it worked fine with the previous version, and since the functionality is critical to you, please feel free to download the previous version of the plugin by visiting the link https://wordpress.org/plugins/forminator/advanced/ Scroll down to “previous versions”
You can also subscribe to our roadmap https://wpmudev.com/roadmap/ or refer to the changelog https://wordpress.org/plugins/forminator/#developers as we’ll be including information of the fix there when it comes to our future releases.
Kind Regards,
SaurabhThank you for your help. What if I roll back to a previous version of Forminator so it won’t delete my forms and data?
-
This reply was modified 2 months, 1 week ago by
mudassiriftikhar.
Also which version should I roll back?
I hope this message finds you well.
What if I roll back to a previous version of Forminator so it won’t delete my forms and data?
Please make sure you have the “Preserve” options enabled at Forminator >> Settings >> Data >> Uninstallation so that the settings and data won’t be removed on uninstallation. Re-installing an old version of the plugin with the Preserve option enabled will ensure no data will be lost.
https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#uninstallation
Also which version should I roll back?
Since you observed the issue after performing an update, please try downgrading the plugin to the previous version, which is version 1.51. I hope that helps.
Please feel free to get back to us if you need any further clarification.
Best Regards,
Nebu JohnThank you so much for the help.
I would like to update you regards the current issue, we confirmed it is a bug in the plugin, unfortunately, the fix requires updating the plugin code but we already reported it to our developers.
We can’t give an estimated time yet for the fix but subscribing to our roadmap https://wpmudev.com/roadmap/ is a good way to be posted about upcoming versions, once they are released, it is going to be described at changelog found on https://wordpress.org/plugins/forminator/#developers
Since the bug was acknowledged, reported and tasked to be fixed, we are marking this as resolved, but feel free to let us know if you have any additional questions.
Best Regards
Patrick FreitasHello, thanks for the update please let me know when this bug fixed so I can update on my end.
I am afraid we don’t update the thread as we don’t have an ETA but I see we plan it for 1.54 if everything goes well in the development and testing.
Best Regards
Patrick FreitasThank you for this update.
-
This reply was modified 2 months, 1 week ago by
You must be logged in to reply to this topic.