diff --git a/registration.module b/registration.module index 4e75855d2a1e71bfe727cd56b5b4692772b0e8ae..d35b0309dad341bb00d20cd9ec0b52a9b67d50e4 100644 --- a/registration.module +++ b/registration.module @@ -298,9 +298,11 @@ function registration_form_views_exposed_form_alter(array &$form, FormStateInter /** * Implements hook_form_FORM_ID_alter(). */ -function registration_form_workflow_delete_form_alter(array &$form, +function registration_form_workflow_delete_form_alter( + array &$form, FormStateInterface $form_state, - $form_id) { + $form_id, +) { // If there are no actions, the delete is not allowed. Alter the error // message to mention registration types. if (empty($form['actions'])) { @@ -311,9 +313,11 @@ function registration_form_workflow_delete_form_alter(array &$form, /** * Implements hook_form_FORM_ID_alter(). */ -function registration_form_workflow_state_delete_form_alter(array &$form, +function registration_form_workflow_state_delete_form_alter( + array &$form, FormStateInterface $form_state, - $form_id) { + $form_id, +) { // If there are no actions, the delete is not allowed. Alter the error // message to mention registration types. if (empty($form['actions'])) { @@ -324,9 +328,11 @@ function registration_form_workflow_state_delete_form_alter(array &$form, /** * Implements hook_field_widget_complete_WIDGET_TYPE_form_alter(). */ -function registration_field_widget_complete_datetime_default_form_alter(&$field_widget_complete_form, +function registration_field_widget_complete_datetime_default_form_alter( + &$field_widget_complete_form, FormStateInterface $form_state, - $context) { + $context, +) { // Add timezone to the datetime widgets when editing registration settings. if ($context['items'] ->getFieldDefinition() diff --git a/src/Drush/Commands/RegistrationSanitizeCommands.php b/src/Drush/Commands/RegistrationSanitizeCommands.php index 8efb917ca9f0762f30081db7af9f8468438a7683..143f982640988a2963fff52030ed95e3d4b3e9b4 100644 --- a/src/Drush/Commands/RegistrationSanitizeCommands.php +++ b/src/Drush/Commands/RegistrationSanitizeCommands.php @@ -32,7 +32,7 @@ final class RegistrationSanitizeCommands extends DrushCommands implements Saniti protected Connection $database, protected EntityFieldManagerInterface $entityFieldManager, protected EntityTypeManagerInterface $entityTypeManager, - protected FieldTypePluginManagerInterface $fieldTypePluginManager + protected FieldTypePluginManagerInterface $fieldTypePluginManager, ) { parent::__construct(); } diff --git a/src/Plugin/Field/FieldWidget/RegistrationTypeWidget.php b/src/Plugin/Field/FieldWidget/RegistrationTypeWidget.php index d1ac7ffad4221376a1161e99277f8b8db9ee68a2..aff1fb618aaa3f65b653ac9b346cb02c0cfd73a5 100644 --- a/src/Plugin/Field/FieldWidget/RegistrationTypeWidget.php +++ b/src/Plugin/Field/FieldWidget/RegistrationTypeWidget.php @@ -114,23 +114,29 @@ class RegistrationTypeWidget extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { - $entity = $items->getEntity(); - $entity_type = $entity->getEntityTypeId(); - $entity_bundle = $entity->bundle(); - $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type); - $bundle = $bundle_info[$entity_bundle]['label']; - $default_value = $items[$delta]->get('registration_type')->getValue(); $element['registration_type'] = [ '#type' => 'select', '#title' => $this->t('Registration type'), '#options' => $this->getRegistrationTypeOptions(), '#default_value' => $default_value, - '#description' => $this->t('Select what type of registrations should be enabled for this @type. Depending on the display settings, it will appear as either string, registration link, or form.', [ - '@type' => $bundle, - ]), ]; + // Set the field help. + $element['registration_type']['#description'] = $element['#description']; + if (empty($element['#description'])) { + // Default if field help is blank. + $entity = $items->getEntity(); + $entity_type = $entity->getEntityTypeId(); + $entity_bundle = $entity->bundle(); + $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type); + $bundle = $bundle_info[$entity_bundle]['label']; + + $element['registration_type']['#description'] = $this->t('Select what type of registrations should be enabled for this @type. Depending on the display settings, it will appear as either string, registration link, or form.', [ + '@type' => $bundle, + ]); + } + return $element; }