function datalayer_form_field_config_form_alter in dataLayer 8
Implements hook_form_FORM_ID_alter() for 'field_config_edit_form'.
File
- ./
datalayer.module, line 20 - Client-side data space.
Code
function datalayer_form_field_config_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$datalayer_settings = \Drupal::config('datalayer.settings');
if ($datalayer_settings
->get('output_fields')) {
$field = $form_state
->getFormObject()
->getEntity();
$form['third_party_settings']['datalayer']['expose'] = [
'#type' => 'checkbox',
'#title' => t('Expose in dataLayer'),
'#default_value' => $field
->getThirdPartySetting('datalayer', 'expose', 0),
'#description' => t('Checking this box will result in this field being included in the dataLayer object.'),
];
$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.'),
];
}
}