Brief
I'm using Entityform with Field group configured as Multipage with AJAX enabled for multipage groups provided by Field Group Ajaxified Multipage. So there are multiple steps and user can access (jump into) these steps through provided Multipage jumplist block.
See some sample images (to give you some visual idea):
Problem
The problem is that form is AJAX (dynamic) and jumplist block is static (which is unaware of form context and links doesn't work) with some basic jQuery code (so it's not reloaded when user goes to next pages).
As result this is what happens:
- when field_group multipage is AJAX, the form validation works per step, but jumplist doesn't work (jQuery events are not attached to the links and other steps are not available as it needs to be loaded via AJAX),
- when field_group multipage is not AJAX, the jQuery events works, so you can switch between pages, but the server-side validation doesn't work as nothing is submitted on Next button
but I need both to work (server-side validation and jumplist links).
Further info
See also the following related issue.
I'm thinking to do:
- jQuery, but I'm not sure how to access the step the user is in,
rendering navigation block (or jumplist it-self) with the AJAX form (dirty and tricky), e.g.
// Implements hook_form_alter(). $block = module_invoke('multipage_jumplist', 'block_view', 'd07d74b8ad268f8c'); $rendered_block = theme('block', $block); $theme_code = theme('multipage_jumplist', $foo); $form['navigation'] = array('#markup' => $rendered_block);
not to use AJAX, but I need it for step-by-step server-side validation (FGAM+IFE),
create a session variable and pass to the JS (but the page won't be reloaded), or override jumplist theme hook, e.g.
// hook_form_alter - Get step we're in. $step = empty($form_state['storage']['field_group_ajaxified_multipage_step']) ? 1 : $form_state['storage']['field_group_ajaxified_multipage_step']; $curr_step = &$_SESSION[end((arg())) . '-step']; $curr_step = max($step, $curr_step); // theme_multipage_jumplist_item - Parse the jumplist $visited_steps = &$_SESSION[end((arg())) . '-step']; if ($variables['counter'] <= $visited_steps) { // return either clickable item or not. }
customize/patch the module (where to start),
- find some alternative solution
Question
How do I alter/update my multipage jumplist block (unaware of form context) based on the current step user is in having AJAXified form?
By updating I mean either knowing which element is active, or have ability to extend the behaviour and disable further steps (from being clickable) which weren't visited yet.
What's your suggestion? What would be the Drupal-way?