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
- 03.04.24IT / Уроки PHP Уроки простыми словами. Урок 3. Все операторы PHP с примерами, с выводом работы кода на экран.
- 02.04.24IT / Уроки PHP Уроки простыми словами. Урок 2. Типы данных в PHP с примерами.
- 02.04.24IT / Уроки PHP Уроки простыми словами. Урок 1. Коротко о языке веб-программирования PHP. Основы синтаксиса.
- 09.11.23IT / Database Errors when migrating from MySQL 5.6 to 5.7 and how to fix them - database dump import failed with an error or INSERT does not work. Disabling STRICT_TRANS_TABLES strict mode or using IGNORE
- 08.07.22IT / Misc Convert office files DOC, DOCX, DOCM, RTF to DOCX, DOCM, DOC, RTF, PDF, HTML, XML, TXT formats without loss and markup changes