Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nelson-ph/4fa87b84c352397be5723dcd4be1885a to your computer and use it in GitHub Desktop.

Select an option

Save nelson-ph/4fa87b84c352397be5723dcd4be1885a to your computer and use it in GitHub Desktop.
Drupal Password legacy module - fix $roles value on submit
Index: password_policy.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- password_policy.module (date 1531830899000)
+++ password_policy.module (date 1531830899000)
@@ -170,6 +170,10 @@
}
$roles = $form_state->getValue('roles');
+ if (!empty($roles) && !isset($roles[0])) {
+ $roles = array_filter($roles);
+ $roles = array_keys($roles);
+ }
if (empty($roles)) {
// Get if from $form; form state is always empty the first time.
$roles = $form['account']['roles']['#default_value'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment