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

fix form controller redirect with empty context option #3324

Conversation

tim0991
Copy link
Contributor

@tim0991 tim0991 commented Dec 27, 2017

When i delete a data in update page, it will not going to redirect, because i did not specify delete context

so this commit is set defualtRedirect to defualt context if there is no matched context

@LukeTowers
Copy link
Contributor

@tim0991 please test if this code works instead (changing the !isset() to empty() instead)

// Get the redirect for the provided context
$redirects = [$context => $this->getConfig("{$redirectContext}[{$redirectSource}]", '')];

// Assign the default redirect afterwards to prevent the
// source for the default redirect being default[redirect]
$redirects['default'] = $this->getConfig('defaultRedirect', '');
  		  
if (empty($redirects[$context])) {
    return $redirects['default'];
}		
  		  
return $redirects[$context];

@tim0991
Copy link
Contributor Author

tim0991 commented Dec 28, 2017

yes, you are right

@tim0991 tim0991 closed this Dec 28, 2017
@tim0991 tim0991 reopened this Dec 28, 2017
@LukeTowers
Copy link
Contributor

@tim0991 Please test this code. You still haven't added $redirects = [$context => $this->getConfig("{$redirectContext}[{$redirectSource}]", '')]; back in, the current PR just replaces that with $redirects = [];.

If you could also add some unit tests for this functionality that would be greatly appreciated.

@tim0991
Copy link
Contributor Author

tim0991 commented Dec 29, 2017

I'm sorry for my carelessness, and i do not know how to write unit test until now.
But i will learn it, i hope the next time when i push PR can provide the unit test

@LukeTowers
Copy link
Contributor

So are you planning on adding unit tests to this PR or are you talking about doing it in the future?

@tim0991
Copy link
Contributor Author

tim0991 commented Jan 1, 2018

Maybe in the future

@LukeTowers
Copy link
Contributor

Okay, so is this PR done then? Ready to be merged? @tim0991

@tim0991
Copy link
Contributor Author

tim0991 commented Jan 2, 2018

Yes, it is a small change

@LukeTowers LukeTowers merged commit 0783126 into octobercms:develop Jan 2, 2018
flakerimi added a commit to flakerimi/october that referenced this pull request Jan 4, 2018
* commit 'd220cd2d5705d730832b2ec89707fae5b28f2fcb': (38 commits)
  Added ability to list records with colors
  Better check for default deletion redirect (octobercms#3324)
  Use cms.storage.uploads.disk instead of filesystem.default
  Fix 'illegal string offset' warning (octobercms#3331)
  Fixes octobercms#3315
  Fix typo (octobercms#3326)
  Support toggling the removal of stop words in input preset handling (octobercms#3320)
  Trigger fileupload form field change on file removal (octobercms#3319)
  Initialize missing variable (octobercms#3318)
  Bring Finnish language up to date (octobercms#3316)
  Add default ports on database config (octobercms#3308)
  Typo fix
  Allow overriding form config in arbitrary contexts
  Update client.php (octobercms#3292)
  Change default environment to development (octobercms#3288)
  Save relations first in model saver This aligns better with the relation principal "parent saves child" / "child cannot save parent" and is more conducive to the natural workflow of a coder, ie
  Removes non functional buttons in pivot mode Refs https://github.com/daftspunk/oc-test-plugin/issues/28
  Fix deprecated calls. (octobercms#3283)
  Improved inline docs
  Updating validation messages translations (octobercms#3261)
  ...

# Conflicts:
#	config/database.php
#	config/environment.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants