I have an AJAX form with a dropdown menu of Sizes. Whenever I change the Size, the AJAX mechanism changes the Price on the form. The default Size is 180, to this corresponds a price of 100$. The size 200 costs 150$.

Now if I want to prepopulate the form to a size of 200 I do
example.com?edit[attributes][field_size]=200

The Size field is showing 200, as it should.

However, the price is incorrectly showing 100$, corresponding to the default size.

Is this the expected behavior? If so, can you recommend a method to trigger the AJAX mechanism?

Comments

autopoietic’s picture

Category: bug » support

How did you create the AJAX functionality? It sounds like whatever module provides the function that updates the field isn't fired on document load, and that normally would make sense as the defaults would all match up perfectly.

The AJAX mechanism has no way to know that Prepopulate has stolen on in there and changed the form element's default value on this page. Either you adapt the module's js to fire on load, or you could just prepopulate your Price field as well in the same manner as you did the Size field.

I don't think this should really be construed as a bug with the prepopulate module, as the AJAX element is specific to your site.

hope that helps someone.