Account created on 14 June 2023, over 1 year ago
#

Recent comments

phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/drupal/example_module

1. Create a Custom Module

2. Implement hook_help():
In the custom_submission_filter.module file, add the hook_help() implementation to provide information about the module:

/**
* Implements hook_help().
*/
function custom_submission_filter_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.custom_submission_filter':
return '

' . t('Modifies the WebformSubmissionWorkflowListBuilder class to handle empty Workflow Steps data.') . '

';
}
}

3. Implement hook_webform_submission_filter_query_alter():
Now, implement the hook_webform_submission_filter_query_alter() hook to override the WebformSubmissionWorkflowListBuilder class behavior. In the custom_submission_filter.module file, add the following code:

use Drupal\webform\Plugin\WebformHandler\EmailWebformHandler;
use Drupal\Core\Entity\Query\QueryInterface;

/**
* Implements hook_webform_submission_filter_query_alter().
*/
function custom_submission_filter_webform_submission_filter_query_alter(QueryInterface $query, $form_id) {
// Get the Workflow Steps data count.
$workflow_steps_count = count(\Drupal::entityQuery('webform_submission_workflow_step')
->condition('webform', $form_id)
->execute());

// If there are no Workflow Steps data, set the total count to 1.
if ($workflow_steps_count === 0) {
$query->addExpression('1', 'total');
}
}

/**
* Implements hook_form_alter().
*/
function custom_views_hide_remove_checkbox_form_alter(&$form, &$form_state, $form_id) {
// Check if the form is a Views field or sort configuration form.
if (strpos($form_id, 'views_ui_config_item_form') === 0) {
// Remove the "Remove" checkbox element from the form.
unset($form['remove']);
}
}

1. Create a Custom Module:
First, create a custom module in Drupal. You can name it something like "custom_views_hide_remove_checkbox."

2. Implement hook_form_alter():
Within your custom module, implement the hook_form_alter() function to alter the Views configuration forms. This hook allows you to modify form elements before they are rendered on the page.

In the custom module's .module file, add the following code:

/**
* Implements hook_form_alter().
*/
function custom_views_hide_remove_checkbox_form_alter(&$form, &$form_state, $form_id) {
// Check if the form is a Views field or sort configuration form.
if (strpos($form_id, 'views_ui_config_item_form') === 0) {
// Remove the "Remove" checkbox element from the form.
unset($form['remove']);
}
}

In Drupal, the 'Fields' or 'Sort' rearrange dialog you mentioned is likely part of the Views module, which allows you to create, manage, and display lists of content (nodes, users, etc.) on your site. The checkbox you want to remove is probably the "Remove" checkbox that appears next to each field or sort handler in the 'Fields' or 'Sort' configuration forms within the Views UI.

To achieve your goal of hiding the "Remove" checkbox in the 'Fields' or 'Sort' rearrange dialog, you can use a custom module to alter the Views form and remove the checkbox element. Here are the general steps to achieve this:

Create a Custom Module:
First, create a custom module in Drupal. You can name it something like "custom_views_hide_remove_checkbox."

Implement hook_form_alter():
Within your custom module, implement the hook_form_alter() function to alter the Views configuration forms. This hook allows you to modify form elements before they are rendered on the page.

In the custom module's .module file, add the following code:

php
Copy code
/**
* Implements hook_form_alter().
*/
function custom_views_hide_remove_checkbox_form_alter(&$form, &$form_state, $form_id) {
// Check if the form is a Views field or sort configuration form.
if (strpos($form_id, 'views_ui_config_item_form') === 0) {
// Remove the "Remove" checkbox element from the form.
unset($form['remove']);
}
}

3. Enable the Custom Module:
After creating the custom module, place it in your Drupal installation's modules/custom/ directory. Then, go to the Drupal administration panel, navigate to "Extend," and enable the "custom_views_hide_remove_checkbox" module.

4. Clear Cache:
Once the module is enabled, clear Drupal's cache to ensure that the changes take effect.

Production build 0.71.5 2024