You are here

function field_inheritance_entity_form_add in Field Inheritance 8

Same name and namespace in other branches
  1. 2.0.x field_inheritance.module \field_inheritance_entity_form_add()

AJAX Form Callback: Field Inheritance Entity Form.

File

./field_inheritance.module, line 316
Contains field_inheritance.module.

Code

function field_inheritance_entity_form_add(&$form, FormStateInterface $form_state) {
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  $inheritance_entity = \Drupal::entityTypeManager()
    ->getStorage('field_inheritance')
    ->create();
  $inheritance_entity
    ->setDestinationEntityType($entity
    ->getEntityTypeId());
  $inheritance_entity
    ->setDestinationEntityBundle($entity
    ->bundle());
  $response = new AjaxResponse();
  $modal_form = \Drupal::service('entity.form_builder')
    ->getForm($inheritance_entity, 'add');
  $response
    ->addCommand(new OpenModalDialogCommand('Add Field Inheritance', $modal_form, [
    'width' => '800',
  ]));
  return $response;
}