Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Drupal 8 Custom Plugin Types
Sep 14, 2015 @ 16:08:06

The SitePoint PHP blog has posted an overview from Daniel Sipos covering custom plugin types in Drupal 8 and how you can combine them (custom forms) with node entities.

In this article series of two parts, we will use this system to build a feature that allows the use of custom forms together with node entities. After we’re done, we’ll be able to do the following: configure node bundles to use one of multiple form types to be displayed together with the node display and easily define new form types by extending from a sensible base class. [...] We will get started by creating our custom plugin type. T

He starts with the plugin manager, showing you how to create a custom ReusableFormsManager in the module to set up the manager and add it to the system. He then sets up the plugin interface the manager is expecting to find. This piece defines methods to get the name of the plugin and to build the form. He then creates a simple ReusableForm annotation class and builds out the plugin base. This base class includes a form builder object used to build and output the custom form. Finally he gets into building the form and its matching interface. It's a simple "Contact Us" kind of form that outputs three fields (first name, last name, email) and a "Submit" button.

tagged: drupal8 custom plugin type tutorial form contactus

Link: http://www.sitepoint.com/drupal-8-custom-plugin-types/


Trending Topics: