Creating Dynamic Title for Custom page in Drupal 8

In some cases you may need to generate dynamic titles for pages like node view page, you can do it by routing.yml file itself by adding one param

modulename.page:
 path: '/custompage'
 defaults:
  _controller: '\Drupal\modulename\Controller\DemoController::getPage'
  _title_callback: '\Drupal\modulename\Controller\DemoController::getPageTitle'
 requirements:
  _permission: 'access content'

Create src folder in your module path, create controller folder and create DemoController and add getPageTitle method in demo controller class 

Rendering common form in drupal 8 and passing additional parameters

 

You may have scenario where in you need to pass extra parameter to form, using common/same forms in multiple places, You can do it just by passing params in buildform function in your form.

 

 create a .php file under folder structure /src/Form/Formname.php .Then build a drupal 8 form

With extra params in buildForm function

Create Field and Field Type which cannot be created or accessed by user in administration UI in drupal 8

 

In many scenarios you may wish to create fieldtype which cannot be accessed or created by admin user by UI in administration, Say for example 

you are creating a module that module have field type which is only used to do your module related content, it should not be attached to other content type through Admin UI by add fields.

Passing parameter to node add form through URL node/add/termid using routing.yml drupal 8

 

It is used to send extra parameter in arg without using query param, Actually have overwritten the default routing by creating new route and disable the existing route.

Passing term id to node/add  form by url node/add/{termid},  if you pass like you will get page not found error, because it will consider as unknown route, according to drupal node/add and node/add/1 is different, to make it work this , created new route in custom module and called/used the default core node controllers by routing  file.

Add this in modulename.routing.yml file