Calc on save issues

chancar

New Member
Hi,

I have this calc field that performs calculations based upon two previous dorpdowns' choices and an amount to be typed in an imput field.

As the form simulates a calculator I want the calculations to be triggered after pressing the "save" button (which I changed its name for "calculate"). I don't want to do it with ajax because I need to oblige the user to go through the button so the form details are saved in my table.

The problem is that if I leave ajax calc on, then it calculates both with the button and when the field loses focus. But if I set ajax calc off, then it saves the form but does not display any result.

Additionaly, when the form is saved it shows a success message which once closed removes all form's data. And I don't want it. Supress success message option doesn't do anything. What can be done?

Thanks a lot!
 
How do you call the form? In an article?
If you are calling a new (empty) record "save" will return to where you are coming from (i.e. opening the next new (empty) record)

What do you want to achieve?
Every (logged in) user has one record, the last calculation is saved? (use "usekey" and rowid=-1)
Or every calculation should be saved but after "save" it should show the saved record (use "Apply" button instead of "Save")
 
Hi, troester! Thanks for quick reply.

Yes I am calling the form from an article. What I want to achieve is to simulate a calculator. As you can see in the attached image, the user chooses options in two dependent dropdowns and then inputs an amount in a field. Then, after pressing "save", the form is supposed to calculate a new amount and display it.

But at the same time I want to save the details of every calculation for statistic purposes (don't want to make people log in, as the anonymous data is enough for me). Perhaps I'm such a mess...

Thanks.
 

Attachments

  • Calc on save issue.png
    Calc on save issue.png
    9.8 KB · Views: 291
If the calculation is a simple one, then you can set Ajax-calc Off and use Javascript actions to do the calculations.
 
Thanks, Sophist, for your input.

It seems a good approach, however I would like to run the calculations on the server to avoid replications, as they are actually the core of the thing.

Indeed, what really annoys me is the "form saved" message and if I could just remove it I would be happy. Just to make it clear, the message annoys me because it covers my display (the info I want to show to the user) and if you close it or click accept, the result gets cleared.

Any thoughts on this? Many thanks!
 
Edit your form settings and on the Form-processing tab, there is a box for a custom success message and a Suppress Messages dropdown which enables you to suppress success and / or ACL messages.
 
It doesn't work, don't know why. I can set my own sucess message but even if I supress success and/or ACL messages it still shows the default "form saved" message.
 
hi could you point us at the page and then post you form's settings, especially if you have a redirect plugin on the form I'd like to know what settings you have there.
many thanks
Rob
 
I wouldn't say it's a page, just a spot I'm using for Fabrik tests. You can see it in http://legalapps.biz/newo/

I'm afraid I don't have a redirect plug-in. The settings are:

Record in database: Yes
Table name: formbase
Ajax validation: No
Success message:
Suppress Messages:Success & ACL messages
Spoof check:Yes
Save part-edited records: No
Notes:
Cheers!
 
Ah! That's the AJAX success msg, tossed up by the JavaScript. I think troester and myself were thinking about the standard "message area" success message you get after a non-AJAX, "normal" form submit.

I'll take a look at our code for that. Agreed, I think if you suppress msgs, we shouldn't pop that one up either. And I have a feeling I just forgot about that when coding the msg suppression stuff.

-- hugh
 
Ah, when you say you "fixed the code", did you actually do an update from github?

It works fine if I append ?fabrikdebug=1 to that URL, and load the uncompressed JS, which has my fix in it. But with the compressed JS, it doesn't work.

So if all you did was apply those changes to the source files, no it won't work. You need to do a full github update, and re-upload everything. You should pretty much never "cherry pick" github updates, as changes in one commit may well rely on changes in previous commits, and you can end up with some very nasty conflicts if you don't update everything when you update.

-- hugh
 
Thanks a lot, hugh! Shame on me. I just did exactly what you said I shouldn't be doing. After Github update it removes the message (it removed my css's too).

I do not get the annoying message anymore, however now when I press save it does not show the result and clears the input field. With ajax calc it works fine. Is there a way I can "calc on save" and get the result shown in the calc field? Thanks a lot!
 
Not sure where you put your CSS before, but the way to stop them from being overwritten by an update-from-github is to copy the custom_css_example.php file in your template to custom_css.php and put your CSS in there.
 
Strange because I had a "demo1" folder on "components/com_fabrik/views/form/tmpl/" and my css was in the "template_css" file. It all remains the same and the form still uses "demo1" as template, but it doesn't follow it anymore.
 
Well - demo1 is a custom template that you created - so it would not have been overwritten by GitHub.

But of course the Fabrik templates and other code does change over time, so it is possible that you need to update your custom template to match.

(This is a sound reason not to use custom templates unless you really have to. Templates should only be used for layout, and custom templates should only be used when you can't tweak the standard templates with CSS and should not be used to provide either application functionality or element-specific tweaking.)

You might want to check that your form front and back end template settings are still set to demo1.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top