0

Is there a way in the Form API to have a form element display in a table (think like a list of fees) where one of the rows value could be changed with AJAX from another form element?

For example, if the default 'Subscription fee' is $10, and I select a different 'Subscription Plan' method, when I click the option, how do I change that fee row to $20 or whatever the amount may be?

I am trying to utilize the #ajax framework as much as possible with the Form API but I am not seeing how this is easily achievable.

The way I have rendered the form is to assemble the header and rows, then output a form Item element with theme('table') as its #markup, but I am getting an HTML string instead of an actual data array to manipulate (which is its intent, but I need something to manipulate with JS/PHP).

1 Answer 1

1

You might want to take a look at this blog entry that reproduces exactly (what it sounds like) you are trying to do: http://www.computerminds.co.uk/articles/make-link-use-ajax-drupal-7-its-easy

If you post your code it would be easier to troubleshoot.

You might also want to take a look at the code from the ajax_example module in the examples module.

2
  • Not really, I'd need a radio button or checkbox to (when clicked) change one or more values in a table within the form. I've been stuck on this for a while. I haven't seen a more advanced Drupal FAPI ajax example to shed some light on this.
    – Kevin
    Feb 24, 2012 at 18:55
  • You are right that the example blog post uses a link to fire the ajax callback, but using [#ajax] should work with a radio button api.drupal.org/api/drupal/… If you've got some generic code I'd be happy to give it a try
    – acouch
    Feb 24, 2012 at 19:17

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.