Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect or refresh after BetterButtonNestedForm submit #133

Open
adrian-stein opened this issue May 17, 2016 · 2 comments
Open

Redirect or refresh after BetterButtonNestedForm submit #133

adrian-stein opened this issue May 17, 2016 · 2 comments

Comments

@adrian-stein
Copy link

This sort of relates to [https://github.com//issues/126] but could also be classed as a new issue. I can close and comment on the other one if that is the case.

When using BetterButtonNestedFormon an order object I am setting the order as archived and entering an invoice number, I then save the object that I was viewing from the custom action. This saves the object but gives errors. In updateBetterButtonsActionsI have a check to only show the archive button if the order is not archived and when I click the action to archive it I get the error "Action archive doesn't exist or is not a BetterButtonNestedForm". I assume this is because the button is not included as the order is now archived. I guess I can get around this by making sure to add a button that has the same type and action name but does nothing if the order is already archived, but this doesn't sounds like a great way or doing it.

Ideally it should be able to do one of 2 things:

  1. On the saving of the BetterButtonNestedFormit updates the entire page so the archive button is not rendered on the page ( will have to happen before I close the dialog)
  2. On save it redirects to the same page or another page. I can do a Controller::curr()->redirect('admin/orders'); from the custom action but this redirects the iframe in the ssdialog and not the parent page. I dont mind if it redirects back to the list page and shows all orders or the existing page but with updated information.

Is there already a work around to get past this issue? As updating the record you are viewing with a BetterButtonNestedFormseems like a fairly common task, but I note your example doesnt save data just send a message.

Cheers Adrain

@sheadawson
Copy link

+1

@kinglozzer
Copy link

Needed this for a project so hacked something together. It’s horrible (tight deadline, what can I say?) but it works: https://gist.github.com/kinglozzer/076668800c9e4b35ec40d92b3e3f6a00

Just use BetterButtonBetterNestedForm::create() instead of BetterButtonNestedForm::create(). Make sure your actions return a string with a success message, it’ll get added to the parent form (the one outside the dialog) and perform a hard refresh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants