One more tips that are not well documented in Drupal 8 API. In this tutorial i'll go though with creating a custom module which by default create a new page that simply embeding node creation form
Create the module files
1- Create a new folder in /module directory and name it custom_module
2- Create custom_module.info.yml file with the following definition
name: 'Our custom module'
description: 'However !'
core: 8.x
type: module3- Add custom_module.routing.yml with the following details
custom_module_page:
path: 'new/article'
defaults:
_controller: '\Drupal\custom_module\Controller\customModuleArticleController::content'
requirements:
_permission: 'access content'4- create the following file & folders inside our module src/Controller/customModuleArticleController.php with the following code
<?php
/**
* @file
* Contains \Drupal\custom_module\Controller\customModuleArticleController.
*/
namespace Drupal\custom_module\Controller ;
use Drupal\Core\Controller\ControllerBase ;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Component\Utility\Html ;
class customModuleArticleController extends ControllerBase
{
public function content(Request $request) {
$type = node_type_load("article"); // replace this with the node type in which we need to display the form for
$node = $this->entityManager()->getStorage('node')->create(array(
'type' => $type->id(),
));
// OPTIONAL - Set default values for node fields
$node->set('field_age', "32") ;
$node_create_form = $this->entityFormBuilder()->getForm($node);
return array(
'#type' => 'markup',
'#markup' => render($node_create_form),
);
}
}Now, you can create new article from
"new/article" instead of "node/add/article"
Easy right !



