Sign in Registration

Creating a form in Drupal - what types of fields are there


When creating a form in Drupal, you must specify its type for each field. What types of fields exist in Drupal , or rather, which #type can be specified in the form? There are a lot of values, let's list the common ones:

  • checkbox - creates a single checkbox checkbox;
  • checkboxes - creates a field containing checkboxes in the form of many checkboxes;
  • date - field for entering date;
  • fieldset - allows you to create a border around the form;
  • file - a field for uploading a file;
  • machine_name - field for specifying machine name;
  • managed_file - allows you to create a field for uploading a file, with buttons to upload or delete a file right on the edit page;
  • password - field for entering a password;
  • password_confirm - field for confirming the password;
  • radio - radio button field;
  • radios - creates a field containing radio buttons in the form of many radio buttons;
  • select - field for selecting a value from the list;
  • tableselect - creates a table in which you can select a value in the left column using checkboxes or radio buttons;
  • text_format is a field that allows you to enter long text with hyphenation. Optionally, you can choose the format for entering text;
  • textarea - field for entering large text;
  • textfield - simple field for entering short values;
  • vertical_tabs - creates a field in the form of vertical tabs;
  • weight - a field for conveniently specifying the weight of an element.

There are also special types, consider them:

  • actions - A wrapper element for grouping one or more buttons on a form, helps ensure correct theme styling and allows other modules to properly modify form actions. Usually these are buttons "Save", "Delete", "Cancel";
  • button - usually this type is used to create a button for previewing. When the button is clicked, the form will be submitted, where it will be validated and rebuilt, but no submit handler is called;
  • container - the field generates HTML to wrap child elements into the container. Surrounds child elements with the div tag and adds attributes such as classes or id;
  • image_button - image button;
  • submit - button for submitting the form;
  • form - creates a field containing form elements;
  • hidden - creates a hidden field to transfer any additional data;
  • token - a field that allows you to select a token;
  • markup - a field that allows you to set your own HTML markup;
  • item - Creates a display-only form element to provide a title and description;
  • value is a field for setting the form value, which is internal and never displayed on the screen.

As you can see, there are a lot of field types in Drupal - using Form API , you can create almost any input element for any need. We looked at the general and special types of fields that can be created in Drupal.

Comments (0)
For commenting sign in or register.

Latest articles

Popular sections

Eqsash (Tools)

Android app - VK LAST USER ID, отучитель от зависимости и т.д.:
Available on Google Play

Amessage (Communication)

Login to the web version
Android app:
Available on Google Play

Share this

Subscribe to



IT notes - In simple language about the most necessary things (HTML, CSS, JavaScript, PHP, databases, Drupal, Bitrix, SEO, domains, security and more), PDF, 500 p.