A form is a collection of form elements, which are types of plugin in Drupal 8. Plugins are small pieces of swappable functionalities in Drupal 8. Plugins and plugin development are covered in Chapter 7, Plug and Play with Plugins.
Here are some of the most common element properties that can be used:
- weight: This is used to alter the position of a form element in a form. By default, elements will be displayed in the order in which they were added to the form array. Defining a weight allows a developer to control element positions.
- default_value: This gives a developer the ability to prefill the element with a value, for example, when building configuration forms that have existing data or when editing an entity.
- placeholder: This is new to Drupal 8. Drupal 8 provides a new HTML5 support, and this attribute will set the placeholder attribute on the HTML input.
For a complete reference of available form elements and their properties, check out the Drupal.org API documentation page at https://api.drupal.org/api/drupal/elements/.