當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。