Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / form_alter.twig
1 /**
2  * Implements hook_form_alter().
3  */
4 function {{ machine_name }}_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
5   if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
6     $upload_enabled_types = \Drupal::config('mymodule.settings')->get('upload_enabled_types');
7     $form['workflow']['upload_' . $form['type']['#value']] = [
8       '#type' => 'radios',
9       '#title' => t('Attachments'),
10       '#default_value' => in_array($form['type']['#value'], $upload_enabled_types) ? 1 : 0,
11       '#options' => [t('Disabled'), t('Enabled')],
12     ];
13     // Add a custom submit handler to save the array of types back to the config file.
14     $form['actions']['submit']['#submit'][] = 'mymodule_upload_enabled_types_submit';
15   }
16 }