0

I have content type having fields as follows.

first

second

third

Sum1 (first + second +third) - computed filed

xxxx

yyyy

zzzz

Sum2 (xxxx+yyyy+zzzz) - computed field

Grand Total (sum1 + sum2) - computed field

I could achieve this by using computed field module. When I save node, I could able to find sums and Grand Total.

My problem is client wants to see sum1 filed in edit/create form and also wants to update sum1/sum2/Grand Total fields on the fly (dynamically). There are couple of content types having the same requirement.

Before start to write a custom module, I would like to know alternates for this.Any suggestions?

2
  • 1
    When you say your client wants to update the sum fields dynamically, how is that even logically/mathematically plausible? Or, are you asking that after your client modifies any of the first, second, or third fields that the sum fields should automatically update?
    – Jimajamma
    Mar 10, 2014 at 15:20
  • @Jimajamma I mean, whenever client enter/modify the values of first, second,or third fields the sum of these should automatically update 'total' filed.But here my problem is, if I use computed filed (to compute first second third) we can't see that filed in add/edit node form. Mar 11, 2014 at 5:48

1 Answer 1

3

This sounds like cashier functionality. There has been some effort for D6, see Drupal POS (Point of Sales) System. I haven't used this.

Ideally, this would be done with JavaScript (I have once done it for a non-Drupal system).

A cheap workaround would be the Save & Edit module, where you just save the node and continue editing it, effectively updating the calculations. On demand, not automatically.

A smoother workaround would be updating (on demand) the form with ajax. Ajax module has no D7 version, but in the issue queue is mentioned this sandbox project which supposedly can ajaxify the node edit form: Asaf (ajax submit for any form).

You need one extra module for actually displaying Computed field on node edit form: Field extra widgets. Select the widget "read only".

5
  • Thanks Kari Kääriäinen, I'm going to work around your suggestions. Here my problem is If I use computed filed I can't see the filed in node form. I can see that field value at node output only. Mar 11, 2014 at 5:53
  • You're right. There is a module for that ;) Answer edited. Mar 11, 2014 at 10:13
  • Kari Kääriäinen - As you said I've just installed and tried that for computed filed (by selecting widget type Read only). it's showing up in edit form. but not in add form. thanks for the idea:) Mar 11, 2014 at 10:31
  • Oh no. Giving the field a default value would be the next logical step, but that doesn't work either. Mar 11, 2014 at 15:12
  • Kari Kääriäinen - Your modules helped me to solve my problem, by using computed field, field_extrawidgets, & save_edit modules. Ofcourse my way is not the exact solution for my question but client agreed to this :) Mar 17, 2014 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.