当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityTypeManagerInterface::getFormObject方法代码示例

本文整理汇总了PHP中Drupal\Core\Entity\EntityTypeManagerInterface::getFormObject方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTypeManagerInterface::getFormObject方法的具体用法?PHP EntityTypeManagerInterface::getFormObject怎么用?PHP EntityTypeManagerInterface::getFormObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Entity\EntityTypeManagerInterface的用法示例。


在下文中一共展示了EntityTypeManagerInterface::getFormObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: entityForm

  /**
   * {@inheritdoc}
   */
  public function entityForm($entity_form, FormStateInterface $form_state) {
    $operation = 'default';
    $controller = $this->entityTypeManager->getFormObject($entity_form['#entity']->getEntityTypeId(), $operation, FALSE);
    $controller->setEntity($entity_form['#entity']);
    $form_state->set(['inline_entity_form', $entity_form['#ief_id'], 'entity_form'], $controller);

    $child_form_state = $this->buildChildFormState($controller, $form_state, $entity_form['#entity'], $operation, $entity_form['#parents']);

    $entity_form = $controller->buildForm($entity_form, $child_form_state);

    if (!$entity_form['#display_actions']) {
      unset($entity_form['actions']);
    }

    // TODO - this is field-only part of the code. Figure out how to refactor.
    if ($child_form_state->get('inline_entity_form')) {
      foreach ($child_form_state->get('inline_entity_form') as $id => $data) {
        $form_state->set(['inline_entity_form', $id], $data);
      }
    }

    $form_state->set('field', $child_form_state->get('field'));

    $entity_form['#element_validate'][] = [get_class($this), 'entityFormValidate'];

    $entity_form['#ief_element_submit'][] = [get_class($this), 'entityFormSubmit'];
    $entity_form['#ief_element_submit'][] = [get_class($this), 'submitCleanFormState'];

    // Allow other modules to alter the form.
    $this->moduleHandler->alter('inline_entity_form_entity_form', $entity_form, $form_state);

    return $entity_form;
  }
开发者ID:joebachana,项目名称:usatne,代码行数:36,代码来源:EntityInlineForm.php

示例2: getEntityForm

 /**
  * Gets the entity form for this menu.
  *
  * @param \Drupal\system\MenuInterface $entity
  *   The menu entity.
  *
  * @return \Drupal\Core\Entity\EntityFormInterface
  *   The entity form.
  */
 protected function getEntityForm(MenuInterface $entity)
 {
     $entity_form = $this->entityTypeManager->getFormObject('menu', 'edit');
     $entity_form->setEntity($entity);
     return $entity_form;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:SystemMenuOffCanvasForm.php


注:本文中的Drupal\Core\Entity\EntityTypeManagerInterface::getFormObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。