Update multiple fields using observe_field call


#1

Good day.
I have successfully implemented the observe_field method to update a
single entity in a form dynamically when called.
However, I have a situation that requires I update multiple entities in
the form from a change in a single input.

For example, I want to auto-populate the address for a given customer
when that customer is selected (this works just fine).
However, I also want to also auto-update the customer’s credit limit and
current balance when the customer is selected.
I have attempted to place a separate observer_field call for each of the
address, credit limit, and current balance with no avail.
I do not get an error in the log file and nothing is updated (even the
address) when all three observe_field calls are in place.

Here are the calls:
<%= observe_field(:purchase_order_customer_id,
:update => :po_customer_address,
:url => { :action => :get_customer_address},
:with => “‘customer_id=’+escape(value)”)%>
<%= observe_field(:purchase_order_customer_id,
:update => :po_credit_limit,
:url => {:action => :get_customer_credit_limit},
:with => “‘customer_id=’+escape(value)”)%>
<%= observe_field(:purchase_order_customer_id,
:update => :po_current_balance,
:url => {:action => :get_customer_balance},
:with => “‘customer_id=’+escape(value)”)%>

Here is the controller code: (to me this is very repetitive but due to
the layout of the screen, I can’t set all form inputs with one call)
def get_customer_address
form_customer_id = params[:customer_id]
@found_customer = Customer.find(form_customer_id)
end

def get_customer_credit_limit
form_customer_id = params[:customer_id]
@found_customer = Customer.find(form_customer_id)
end

def get_customer_balance
form_customer_id = params[:customer_id]
@found_customer = Customer.find(form_customer_id)
end

The get_customer_credit_limit rhtml file is as follows (other two are
quite similar)
<%= text_field(“purchase_order”, “customer_credit_limit”, :readonly =>
“readonly”, :value => @found_customer.credit_limit) %>

Is this even possible to do? Or am I so far out in the weeds, I might as
well break camp and head back to base?

Thanks,
M Damon H.
Project Manager
IFWORLD, Inc.
www.ifworld.com http://www.ifworld.com/
“…as we’re sung to sleep by philosophies that sing save the trees and
kill the children…” – while you were sleeping (casting crowns)