Commit c856dfeb authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3270893 by RenatoG: Add the new option to use multiple textfield instead of longtextfield

parent 619d9f78
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ class BlockClassSettingsForm extends ConfigFormBase {
      '#options' => [
        'textfield' => $this->t('textfield'),
        'textarea' => $this->t('textarea'),
        'multiple_textfields' => $this->t('Multiple textfields'),
      ],
      '#default_value' => $field_type,
    ];
+33 −11
Original line number Diff line number Diff line
@@ -365,10 +365,12 @@ class BlockClassHelperService {

      $image_path = '/' . drupal_get_path('module', 'block_class') . '/images/';

      if ($field_type == 'textfield' || $field_type == 'textarea') {

        $form['third_party_settings']['block_class']['classes'] = [
          '#type' => $field_type,
          '#title' => $this->t('CSS class(es)'),
        '#description' => $this->t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces. The maxlength configured is @maxlength_block_class_field@. If necessary you can update it <a href="/admin/config/content/block-class/settings">here</a>. This class will appear in the first level of block. <a href="@image_path@example-1.png">Click here</a> to see a example', [
          '#description' => $this->t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces. The maxlength configured is @maxlength_block_class_field@. If necessary you can update it <a href="/admin/config/content/block-class/settings">here</a>. This class will appear in the first level of block. <a href="@image_path@/example-1.png">Click here</a> to see a example', [
            '@maxlength_block_class_field@' => $maxlength_block_class_field,
            '@image_path@' => $image_path,
          ]),
@@ -376,6 +378,26 @@ class BlockClassHelperService {
          '#maxlength' => $maxlength_block_class_field,
        ];

      }

      if ($field_type == 'multiple_textfields') {

        for ($i = 0; $i <= 10; $i++) {

          $form['third_party_settings']['block_class']['classes_' . $i] = [
            '#type' => 'textfield',
            '#title' => $this->t('CSS class(es)'),
            '#maxlength' => $maxlength_block_class_field,
          ];

          if ($i >= 1) {
            $form['third_party_settings']['block_class']['classes_' . $i]['#attributes']['class'][] = 'hidden-class-field';
          }

        }

      }

      $form['third_party_settings']['block_class']['classes']['#attributes']['class'][] = 'block-class-class';

      if (!empty($config->get('enable_attributes'))) {