Commit 1f3d9fac authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3269581 by RenatoG: Insert the new custom attribute field only if is...

Issue #3269581 by RenatoG: Insert the new custom attribute field only if is enabled in the settings page
parent d4fdfd54
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -133,6 +133,11 @@ class BlockClassHelperService {
      $entity->unsetThirdPartySetting('block_class', 'classes');
    }

    // If there is no custom attributes, unset the Third Party Setting.
    if (empty($entity->getThirdPartySetting('block_class', 'custom_attributes'))) {
      $entity->unsetThirdPartySetting('block_class', 'custom_attributes');
    }

    // Get the config object.
    $config = $this->configFactory->getEditable('block_class.settings');

@@ -297,6 +302,16 @@ class BlockClassHelperService {
        '#maxlength' => $maxlength_block_class_field,
      ];

      if (!empty($config->get('enable_custom_attributes'))) {
        $form['third_party_settings']['block_class']['custom_attributes'] = [
          '#type' => 'textfield',
          '#title' => $this->t('Custom Attributes'),
          '#description' => $this->t('Here you can insert any attributes, for example: data-attribute-invite=new-data'),
          '#default_value' => $block->getThirdPartySetting('block_class', 'custom_attributes'),
          '#maxlength' => 255,
        ];
      }

      if (empty($block->getThirdPartySetting('block_class', 'classes'))) {
        $form['third_party_settings']['block_class']['classes']['#autocomplete_route_name'] = 'block_class.autocomplete';
      }