- π©πͺGermany vistree
Hi, I need exactly the same. Instead of just changing the label / title, I need the option for the editor to choose the correct bundle from my custom entity. Is this somehow possible?
- π©πͺGermany vistree
Thanx again @texas-bronius for your initial comment. I think I were able to find a working solution for my "NON translatable" custom entity.
Within a custom module, I addeduse \Drupal\Core\Form\FormStateInterface; function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == 'MYCUSTOMENTITY_FORM_replicate_form') { $form['new_bundle'] = [ '#type' => 'select', '#title' => t('Bundle Type'), '#default_value' => 'unuiqe', '#options' => ['global' => t('Global'), 'unique' => t('Unique')], '#description' => t('Select the target bundle type'), '#weight' => -1, ]; array_unshift($form['actions']['submit']['#submit'], '_mymodule_replicate_form_submit'); } } function _mymodule_replicate_form_submit($form, FormStateInterface $form_state) { $entity = $form_state->getFormObject()->getEntity(); $bundle = $form_state->getValue("new_bundle"); $entity ->set('bundle', $bundle); }
Hope this is the right way of implementation ;-)