You are here

function domain_access_form_devel_generate_form_content_alter in Domain Access 8

Implements hook_form_FORM_ID_alter().

Add options for domains when using Devel Generate.

1 call to domain_access_form_devel_generate_form_content_alter()
domain_access_form_devel_generate_form_user_alter in domain_access/domain_access.module
Implements hook_form_FORM_ID_alter().

File

domain_access/domain_access.module, line 208
Domain-based access control for content.

Code

function domain_access_form_devel_generate_form_content_alter(&$form, &$form_state, $form_id) {

  // Add our element to the Devel generate form.
  $form['submit']['#weight'] = 10;
  $list = [
    'random-selection' => t('Random selection'),
  ];
  $list += \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->loadOptionsList();
  $form['domain_access'] = [
    '#title' => t('Domains'),
    '#type' => 'checkboxes',
    '#options' => $list,
    '#weight' => 2,
    '#multiple' => TRUE,
    '#size' => count($list) > 5 ? 5 : count($list),
    '#default_value' => [
      'random-selection',
    ],
    '#description' => t('Sets the domains for created nodes. Random selection overrides other choices.'),
  ];
  $form['domain_all'] = [
    '#title' => t('Send to all affiliates'),
    '#type' => 'radios',
    '#options' => [
      'random-selection' => t('Random selection'),
      'yes' => t('Yes'),
      'no' => t('No'),
    ],
    '#default_value' => 'random-selection',
    '#weight' => 3,
    '#description' => t('Sets visibility across all affiliates.'),
  ];
}