function FormTestController::twoFormInstances
Returns two instances of the node form.
Return value
string A HTML-formatted string with the double node form page content.
1 string reference to 'FormTestController::twoFormInstances'
- form_test.routing.yml in core/
modules/ system/ tests/ modules/ form_test/ form_test.routing.yml  - core/modules/system/tests/modules/form_test/form_test.routing.yml
 
File
- 
              core/
modules/ system/ tests/ modules/ form_test/ src/ Controller/ FormTestController.php, line 24  
Class
- FormTestController
 - Controller routines for form_test routes.
 
Namespace
Drupal\form_test\ControllerCode
public function twoFormInstances() {
  $user = $this->currentUser();
  $values = [
    'uid' => $user->id(),
    'name' => $user->getAccountName(),
    'type' => 'page',
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ];
  $node1 = $this->entityTypeManager()
    ->getStorage('node')
    ->create($values);
  $node2 = clone $node1;
  $return['node_form_1'] = $this->entityFormBuilder()
    ->getForm($node1);
  $return['node_form_2'] = $this->entityFormBuilder()
    ->getForm($node2);
  return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.