Having issues trying to return new rows in an AJAX-driven tableselect...
- PeachyPaul
- Topic Author
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
5 years 6 months ago #8105
by PeachyPaul
Long story short, I've created a tableselect in a custom module and the form this belongs to has a textfield that I plan on using as a means of searching a database for specific IDs. Based on the IDs found, it will then instigate an AJAX callback to update the tableselect rows.
I've managed to get the textfield to fire off an AJAX callback via both blur and enter actions but I'm having problems getting the new table (with new options) to be updated within the AJAX callback. From all the examples I'm seeing all over the internet, it seems that $form and $form_state are returned in the AJAX callback interchangeably. Which one needs to be returned? It makes sense to believe that it would be $form_state as this would have the updated values...
...but once you know which object to return, how do you update the table exactly?
Below is the AJAX callback:
function mymodule_accounts_management_ajax_callback($form, &$form_state){
drupal_set_message('mymodule_accounts_management_ajax_callback');
The problem I'm having with the AJAX callback that gets fired after the textfield experiences blur is that the table shows "No content available." Oddly enough, if I display the contents of $form, the new fields that I set in the AJAX callback are there... It's like the table just doesn't get returned correctly from in the callback.
Do I need to use $form_state instead and rebuilt the form inside the AJAX callback?
Any insight into this would be appreciated.
I've managed to get the textfield to fire off an AJAX callback via both blur and enter actions but I'm having problems getting the new table (with new options) to be updated within the AJAX callback. From all the examples I'm seeing all over the internet, it seems that $form and $form_state are returned in the AJAX callback interchangeably. Which one needs to be returned? It makes sense to believe that it would be $form_state as this would have the updated values...
...but once you know which object to return, how do you update the table exactly?
Below is the AJAX callback:
function mymodule_accounts_management_ajax_callback($form, &$form_state){
drupal_set_message('mymodule_accounts_management_ajax_callback');
The problem I'm having with the AJAX callback that gets fired after the textfield experiences blur is that the table shows "No content available." Oddly enough, if I display the contents of $form, the new fields that I set in the AJAX callback are there... It's like the table just doesn't get returned correctly from in the callback.
Do I need to use $form_state instead and rebuilt the form inside the AJAX callback?
Any insight into this would be appreciated.
Please Log in or Create an account to join the conversation.