You are here

function scheduler_extras_form_alter in Scheduler 2.x

Implements hook_form_alter().

File

tests/modules/scheduler_extras/scheduler_extras.module, line 16
Hook implementations for the Scheduler Extras test module.

Code

function scheduler_extras_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Only continue if the form is form adding the standard test entity types.
  if (!in_array($form_id, [
    'node_testpage_form',
    'media_test_video_add_form',
    'commerce_product_test_product_add_form',
  ])) {
    return;
  }

  // Hide the time element when the scheduler field exists.
  if (isset($form['publish_on'])) {
    $form['publish_on']['widget'][0]['value']['#date_time_element'] = 'none';
  }
  if (isset($form['unpublish_on'])) {
    $form['unpublish_on']['widget'][0]['value']['#date_time_element'] = 'none';
  }
}