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

Issue #3476285: Hide path field from Nationality taxonomy #4242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,32 @@ function social_profile_fields_update_130001(): void {
];
user_role_grant_permissions('sitemanager', $permissions);
}

/**
* Hidden path from Nationality taxonomy.
*/
function social_profile_fields_update_130002(): void {
$storage = \Drupal::entityTypeManager()->getStorage('entity_form_display');
$form_display = $storage->load('taxonomy_term.nationality.default');

// If the entity-form-display isn't found, return early.
if (empty($form_display)) {
\Drupal::logger('social_profile_fields')->info('The entity-form-display from Nationality taxonomy is empty.');
return;
}

// Get fields and check if path is already be hidden.
$hidden = $form_display->get('hidden');
$content = $form_display->get('content');
if (in_array('path', array_keys($hidden))) {
\Drupal::logger('social_profile_fields')->info('The path field already is hidden on Nationality taxonomy.');
return;
}

// Manipulate path field to be hidden and save.
$hidden['path'] = TRUE;
unset($content['path']);
$form_display->set('hidden', $hidden)
->set('content', $content)
->save();
}
Loading