0

I've used Draggableviews 7.x-2.1 module to enable drag & drop options for particular views. It works well.

I've enabled cache for Anonymous users. Due to this, after save the ordering, the changes didn't affect orders for Anonymous users.

So I've tried to clear cache after submitting handler of draggable views. I've used below code:

function phponwebsites_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_form_test_views') {
    $form['#submit'][] = 'phponwebsites_draggable_custom_submit';
  }
}

function phponwebsites_draggable_custom_submit(&$form, $form_state) {
  print_r('ss');exit;
  drupal_flush_all_caches();
}

But my custom submit handler doesn't call. Is any other solutions?

1 Answer 1

1

Sometimes "#submit" functions of HOOK_form_alter are get changes. SO please try adding $form['#after_build']. Your code will be like.

function phponwebsites_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_form_test_views') {
    $form['#after_build'][] = 'phponwebsites_draggable_custom_afterbuild';
  }
}
function phponwebsites_draggable_custom_afterbuild($form, $form_state) {   
  $form['#submit'][] = 'phponwebsites_draggable_custom_submit'; 
  return $form;
}
function phponwebsites_draggable_custom_submit(&$form, $form_state) {
  print_r('ss');exit;
  drupal_flush_all_caches();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.