本文整理汇总了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;
}
示例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;
}