I am looking for help with a drupal 7 issue.  I need to bring additional reference fields into a form to use in calculations - i.e. enter a customer name and bring back their customer info for use in the form (not just name but additional fields). I need the fields available in the form to do calculations before I save the form.   Entity reference and token didn't work for that reason - the fields were not populated immediately.  I didn't see any to do it using webform / taxonomy.

Example - The user chooses a Customer from a select list (populated via taxonomy or entity reference or other means- the customers are not hard-coded into the form).  The reference data has a number of customer fields associated with it.

Once the Customer is chosen, data fields 1 and 2 populate.  The user enters more data (call it entry 1) into a field and another field is populated using a calculation.  (Customer Data 1 - entry 1) * customer data 2 = current value 1 .

How could I do that?  I need the fields available in the form for calculations before saving.  I'm flexible as to how I do it, just trying to do with a minimum of coding and expense.

Thanks for any help or suggestions in advance,

Elisabeth

Comments

ykarthikvarma’s picture

I believe its gonna be more than "little" coding :)

Refer : https://www.drupal.org/docs/7/api/javascript-api/ajax-forms-in-drupal-7

egarbeil’s picture

Ykarthikvarma, I don't think this is what I need.  I don't need to change the form itself.  The fields are there, I need to grab values to populate those fields in order to do calculations.  It's very interesting though, and I'll keep Ajax forms in mind for the future in case I need to use them.

ykarthikvarma’s picture

In that case try Computed field or Conditional field modules.

egarbeil’s picture

Computed or conditional fields are not used for bringing in data from other entities.  I will be using computed fields separately to do the calculations, but the data has to be there first in order to perform the calculation.

egarbeil’s picture

 I found a really nifty module to exactly what I need with a minimum of coding.  It works very well, with the caveat that you have to save the field before the autopopulate is available and then go back into the field settings to add the autopopulate data. 

https://www.drupal.org/project/entityreference_autofill