I need to put some ajax buttons on each row of table.
My theme looks like this:
/** * Implements hook_theme(). */ function application_wizard_theme($existing, $type, $theme, $path) { return array( 'application_wizard_table' => array( 'render element' => 'element' ), ); } function theme_application_wizard_table($vars) { extract($vars); $header = $element['#header']; $header['operations'] = array('data' => t('Operations')); $rows = $element['#rows']; foreach ($rows as $key => $row) { foreach ($row as $fieldKey => $field) { $fieldValue = $field[$fieldKey][LANGUAGE_NONE]['0']['value']; $rows[$key][$fieldKey] = $fieldValue; } $operations = array(); $operations['delete'] = array( '#type' => 'submit', '#value' => t('Delete'), '#ajax' => array( 'wrapper' => 'wizard-form-wrapper', 'callback' => 'application_wizard_callback' ), ); $rows[$key]['operations'] = drupal_render($operations); } return theme('table', array( 'header' => $header, 'rows' => $rows, ) ); } function application_wizard_callback($form, $form_state) { return $form; } function application_wizard_submit($form, &$form_state) { if ($form_state['triggering_element']['#value'] == t('Delete')) { dpm($form_state['triggering_element']); } }
There is no action when I click on generated Delete buttons. In other words, buttons doesn’t work.
I have no clue what I am doing wrong so I was hoping someone could tell me thank you in advance.