You are here

public function MentionsTypeForm::changeEntityTypeInForm in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  2. 8 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  3. 8.2 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  4. 8.3 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  5. 8.4 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  6. 8.5 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  7. 8.6 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  8. 8.7 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  9. 8.8 modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  10. 10.3.x modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  11. 10.1.x modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()
  12. 10.2.x modules/custom/mentions/src/Form/MentionsTypeForm.php \Drupal\mentions\Form\MentionsTypeForm::changeEntityTypeInForm()

File

modules/custom/mentions/src/Form/MentionsTypeForm.php, line 266

Class

MentionsTypeForm
Class MentionsTypeForm.

Namespace

Drupal\mentions\Form

Code

public function changeEntityTypeInForm(array &$form, FormStateInterface $form_state) {
  $entitytype_state = $form_state
    ->getValue([
    'input',
    'entity_type',
  ]);
  $entitytype_info = $this->entityTypeManager
    ->getDefinition($entitytype_state);
  $id = $entitytype_info
    ->getKey('id');
  $label = $entitytype_info
    ->getKey('label');
  if ($entitytype_state == 'user') {
    $label = 'name';
  }
  unset($form['input']['inputvalue']['#options']);
  unset($form['input']['inputvalue']['#default_value']);
  $form['input']['inputvalue']['#options'][$id] = $id;
  $form['input']['inputvalue']['#options'][$label] = $label;
  $form['input']['inputvalue']['#default_value'] = $id;
  return $form['input']['inputvalue'];
}