Skip to main content
deleted 4 characters in body
Source Link

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if (array_key_exists('field_domain_access', $form)) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if (array_key_exists('field_domain_access', $form)) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if (array_key_exists('field_domain_access', $form)) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system good enough yet.

added 18 characters in body
Source Link

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if ($form['field_domain_access']array_key_exists('field_domain_access', $form)) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if ($form['field_domain_access']) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if (array_key_exists('field_domain_access', $form)) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.

Source Link

As @apaderno mentioned, one possible solution is to manipulate the form field (field_domain_access).

function module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  try {
    if ($form['field_domain_access']) {
      $node = $form_state->getFormObject()->getEntity();

      if ($node->isNew()) {
        $form['field_domain_access']['widget']['#default_value'] = ['www_example_ch', 'www_example_com'];
      }
    }
  } catch(\Throwable $any) {
    \Drupal::logger('global')->info('Exception: %msg', ['%msg' => $any->getMessage() ]);;
  }
}

I'm not a big fan of this approach. Probably I don't understand the system not good enough yet.