Created
March 17, 2020 17:49
-
-
Save ozin7/47b36772c4e1ed9b754eb00dca8ac298 to your computer and use it in GitHub Desktop.
Drupal 8: How to add third party settings which will be saved automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_FORM_ID_alter() for 'field_config_edit_form'. | |
*/ | |
function datalayer_form_field_config_form_alter(&$form, FormStateInterface $form_state, $form_id) { | |
$field = $form_state->getFormObject()->getEntity(); | |
$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.'), | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment