0

I want to create multi step form based on tabs created using Fieldgroups. I have been able to alter the ECK form as well as added my own custom submit handler.

In the custom submit handler, I have added a form redirect that redirects to the same form but with a fragment so that the next tab gets shown. I am able to generate the fragment for the route, but its not working. In-fact, the redirect seems to not work at all for any valid internal route. Kindly advise.

Please find the form redirect url.

$url = new Drupal\Core\Url('eck.entity.add'
, ['eck_entity_type' => 'registration_configuration' , 'eck_entity_bundle' => 'config_2']
, ['fragment' => 'edit-group-add']);
$form_state->setRedirectUrl($url);
  • Can you verify this code is being hit? – Kevin Sep 7 '17 at 15:39
  • @Kevin, my form submit code is getting called. I realized the problem was due to the form submit calling the setRebuild() method. – Amit Sedai Sep 8 '17 at 7:56
1

I was executing setRebuild()! I added another submit button and started doing the steps in my previous submit logic one by one, then it hit me. Form redirection will not happen if your submit is rebuilding the same form :)

$form_state->setRebuild();

Your Answer

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

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