Permission form validate not working with multilingual site.

Created on 28 July 2023, over 1 year ago
Updated 18 October 2023, about 1 year ago

Problem/Motivation

My multilingual site using Filter Permissions module. When I switch to a language other than Eng, i got the error of https://www.drupal.org/project/filter_perms/issues/2546947 πŸ› Permissions unassigned when using multiple windows/tabs on same session Fixed again.

Steps to reproduce

1. Switch to a language other than Eng
2. Open one window/tab and filter permissions for any one role and all modules.
3. Open another window/tab and filter permissions for another one role and all modules.
4. Save permissions on the 1st window/tab.

Then all permissions for the role in the 2nd window/tab are now completely unassigned. With another language, button's value will display differently than "Save permissions", so the conditions if ($submit_button['#value']->render() == 'Save permissions') { will not work.

Proposed resolution

It's better if give the submit button a value that we can detect when click "Save permissions" button. Something like that:
build form:
$form["actions"]["submit"]['#saved_permission'] = TRUE;
validate condition will be:

$submit_button = $form_state->getTriggeringElement();
  // no need to run this validation when submitting filter changes.
  if (isset($submit_button['#saved_permission'])) {
πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡»πŸ‡³Vietnam ducviethaboo Ha Noi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024