Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chered/3330c12dc9bf0619b2fc5dc04523bc1e to your computer and use it in GitHub Desktop.
Save chered/3330c12dc9bf0619b2fc5dc04523bc1e to your computer and use it in GitHub Desktop.
In my mytheme.theme file I put the following code and I could both remove the preview button and also change the submit button text.
function mytheme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['contact_message_feedback_form', ])) {
$key = ($form_id == 'contact_message_feedback_form') ? 'actions' : 'basic';
$form[$key]['submit']['#value'] = 'My Submit Message';
$form[$key]['preview']['#access'] = FALSE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment