Commit d698f35f authored by Joe 🤘 Shindelar's avatar Joe 🤘 Shindelar
Browse files

Issue #3102358 by Phil Wolstenholme, eojthebrave: If the field is not being...

Issue #3102358 by Phil Wolstenholme, eojthebrave: If the field is not being included in the dataLayer then hide the 'DataLayer label' field as users won't be interested in it
parent 148103f8
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -22,15 +22,22 @@ function datalayer_form_field_config_form_alter(&$form, FormStateInterface $form
    $field = $form_state->getFormObject()->getEntity();
    $form['third_party_settings']['datalayer']['expose'] = [
      '#type' => 'checkbox',
      '#title' => t('Expose in dataLayer'),
      '#title' => t('Expose field data in JavaScript <code>dataLayer</code> variable.'),
      '#default_value' => $field->getThirdPartySetting('datalayer', 'expose', 0),
      '#description' => t('Checking this box will result in this field being included in the dataLayer object.'),
      '#description' => t("Checking this box will result in this field's value being included in the <code>dataLayer</code> object provided by the dataLayer module."),
    ];
    $form['third_party_settings']['datalayer']['label'] = [
      '#type' => 'textfield',
      '#title' => t('DataLayer label'),
      '#default_value' => $field->getThirdPartySetting('datalayer', 'label', $field->get('field_name')),
      '#description' => t('Enter the label you would like in the datalayer output.'),
      '#description' => t('Enter the label/key to use when adding this field to the <code>datalayer</code> object. Example; <code>dataLayer.fieldName: value</code>'),
      '#states' => [
        'visible' => [
          ':input[name="third_party_settings[datalayer][expose]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
  }