Steps to reproduce:

1. Visit admin/config/search/search-api/add-index
2. Enter name, Select content, and select any server other than "- No server -" (ie: Solr or Database server)
3. Press Save and Edit

Expected output: Goes to Index edit form
Actual output: Goes to 'View' index.

The only case when it works is when you select 'No server', because no batch is create, but even then it does not redirect to 'Edit', but to 'Fields'.

I suggest to remove 'Save and Edit'. The method Drupal\search_api\Form\IndexForm::save() is creating a batch, so '::redirectToFieldsForm' never gets called.
If you agree, I can submit a patch for it ...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cristiroma created an issue. See original summary.

drunken monkey’s picture

From the batch operations structure that gets created (you see when debugging) I'd actually have thought that after the batch this should/would redirect to "Fields" (not "Edit"), like before we had the batch. However, you are right, this does seem to mess with things. I think we should rather remove the "Save" button and make the redirect work – but I have no idea, how, myself, I have to admit. Maybe we need to adapt the batch's "finished" callback?

In any case, thanks for reporting the issue!

drunken monkey’s picture

Issue tags: +Release blocker

This is definitely a release blocker. If we can't get it to work, we should remove the button. (It already works correctly when creating a disabled index, but that's probably too uncommon to be worth anything.)

rbayliss’s picture

Status: Active » Needs review
FileSize
1.91 KB

It seems like as soon as that batch is set, no other submit callbacks will run. Here's one way to fix it, although it's a bummer that this form could never have additional submit handlers (like if I needed to add one in another contrib module).

dazz’s picture

This seems to fix it but shouldn't the button say "Save and add fields", since it redirects to the add fields page?

borisson_’s picture

Status: Needs review » Needs work

@dazz: that sounds like a good idea, can you change that?

dazz’s picture

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: index_save_and_edit-2575641-7.patch, failed testing.

dazz’s picture

Status: Needs work » Needs review
FileSize
2.84 KB
903 bytes

Adjusted the test.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Back to rtbc, looks great.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review

Yes, does look pretty good. Thanks!
Just corrected two comments (Joris didn't spot a premature line wrap – the end is nigh! ;O) and changed to an – in my opinion – slightly neater way of specifying which URL to redirect to.
If everyone's fine is this, I can commit.

drunken monkey’s picture

Status: Needs review » Needs work

The last submitted patch, 13: 2575641-12--fix_save_and_edit.patch, failed testing.

drunken monkey’s picture

Priority: Minor » Normal
Status: Needs work » Needs review
FileSize
1.07 KB
3.07 KB

OK, this would fail when creating a new index – makes sense.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot for reviewing!
Committed.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.