Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created March 18, 2016 17:36
Show Gist options
  • Save bangpound/edc76d0358371ee6e1da to your computer and use it in GitHub Desktop.
Save bangpound/edc76d0358371ee6e1da to your computer and use it in GitHub Desktop.
<?php
/**
* Form alter that just disables the preview button.
*/
function caxy_form_contact_message_feedback_form_alter(&$form, FormStateInterface $form_state) {
$form['actions']['preview']['#access'] = FALSE;
}
/**
* Form alter that disables the preview button and replaces a value of a form element.
*/
function caxy_form_contact_message_job_posting_form_form_alter(&$form, FormStateInterface $form_state) {
if (Drupal::request()->attributes->has('node')) {
/** @var \Drupal\node\Entity\Node $node */
$node = Drupal::request()->attributes->get('node');
$form['subject'] = array(
'#type' => 'value',
'#value' => $node->getTitle(),
);
}
$form['actions']['preview']['#access'] = FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment