0

I have a form with a table that displays a number of rows (each row contains user info). On form submit I edit all the users that are displayed in the table. Above the table I render a ctools link "Add user". This opens a modal dialog containing a form. After form submit I'm adding a row to the user table with this code:

$output[] = ajax_command_after('.managers-table tr:last', '<tr>my data</tr>');

This works fine, if I look into my DOM, the table contains that row. But here is the tricky part, how do I rebuild my "table-form"? Because when I submit my form, drupal doesn't know a row is added to the table, he just ignores the added row... How can I solve this issue?

  • ctools_ajax_command_redirect() to the same page perhaps? – Clive Oct 23 '14 at 13:25
  • This isn't a solution, because the table contains data that the user can edit. If I perform a redirect al the changes are lost... – Robin Oct 23 '14 at 13:29
  • A custom ajax command is probably your best course of action in that case – Clive Oct 23 '14 at 13:34
  • I want to use $form_state['rebuild'] = TRUE; But how can I get my form state of the table form in my ctools modal form? – Robin Oct 23 '14 at 13:37
  • Don't know off the top of my head - it will likely involve using form_get_cache() to get the form state, then you'll need to alter it and invoke some JS on the front end to force the first form to rebuild itself – Clive Oct 23 '14 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.