Sign in Registration

Drupal Form API - complete list of field properties

When creating Drupal forms need to specify various properties of the fields. There are many such properties, they may differ for different types of fields.


Full list of Drupal field properties:

  • #type - defines the field type, values: checkbox, checkboxes, date, fieldset, file, machine_name, managed_file, password, password_confirm, radio, radios, select, tableselect, text_format, textarea, textfield, vertical_tabs, weight ;
  • #access - is there access to the field or not, values: true, false ;
  • #action - the path on which the form will be sent;
  • #after_build - an array with the names of functions to be called after building the field;
  • #ajax - controls the ajax functionality of the form, values: callback, effect, event, keypress, method, path, prevent, progress, trigger_as, wrapper ;
  • #array_parents - an array of names of the item's parents (including itself) in the form;
  • #attached - Allows loading CSS, JavaScript, libraries or custom types when creating a form;
  • #attributes - additional HTML attributes;
  • #autocomplete_path - AJAX autocomplete script path, used as source for autocomplete;
  • #built - used to determine if a form element was created, values: true, false ;
  • #button_type - adds a CSS class to the button on the form, this does NOT set the HTML attribute type of the button;
  • #children - children of the element;
  • #collapsed - indicates whether the set of fields is collapsed by default, values: true, false ;
  • #collapsible - Indicates whether the set of fields can be generated using JavaScript. Values: true, false ;
  • #cols - how many columns should be in the text box;
  • #default_tab - default open tab;
  • #default_value - the value of the form element that will be displayed or selected initially if the form has not been submitted yet;
  • #delta - the number of weights to select, for example, if the value is 10, numbers from -10 to 10 will be displayed in the weight selection field;
  • #description - the description of the form element, be sure to enclose it inside the t function so that this property can be translated;
  • #disabled - disables the form input element;
  • #element_validate - list of custom functions for field validation;
  • #empty - text displayed if the #options property is empty;
  • #empty_option - the label displayed for the initial option in the list item;
  • #empty_value is the value for the initial parameter in the list item, which is used to determine whether the user has submitted a value or not;
  • #error - Indicates if the form element was marked as an error;
  • #executes_submit_callback - indicates whether the submit handler should be executed when a form is submitted using this button element, values: true, false ;
  • #field_prefix - text or code that is placed immediately before the text field;
  • #field_suffix - text or code that is placed immediately after the text field;
  • #group - specifies a group that can be used to group fields in vertical tabs;
  • #header - column headers;
  • #id - used to fill in the id of the form element;
  • #js_select - enables a checkbox to select all values;
  • #limit_validation_errors - arrays indicating sections to be checked;
  • #markup - used to set HTML that will be displayed in the form;
  • #maxlength - the maximum number of characters to enter as input;
  • #method - HTTP method with which the form will be submitted, by default post ;
  • #multiple - indicates if the user can select more than one value;
  • #name is the name attribute of the corresponding HTML element;
  • #options - selectable options for a form element that allows multiple options;
  • #parents - defines the elements of the parent form;
  • #post_render - function (s) to be executed after rendering;
  • #prefix - text or markup to include before the form element;
  • #pre_render - executable function (s) to call before rendering;
  • #printed - used to determine if a form element has been printed;
  • #process - an array of functions called when processing an element;
  • #processed - used to determine if a form element has been processed;
  • #required - whether the field is required, values: true, false ;
  • #resizable - whether users are allowed to resize the text area;
  • #return_value - value element that should be returned when selected;
  • #rows - how many lines should be in the text field;
  • #size - width of the text field;
  • #src - URL of the button image;
  • #states - adds JavaScript to the element so that it has different active states;
  • #submit - a list of custom submission functions that will be called when an item is submitted;
  • #suffix - text or markup to include after the form element;
  • #theme - theme function to call the element;
  • #theme_wrappers - theme function to call the element after rendering the element and its children;
  • #title - the name of the form element;
  • #title_display - Specifies how the label should be displayed. Values: before, after, invisible, attribute ;
  • #tree - used to create collections of form elements, values: true, false ;
  • #type - used to determine the type of form element;
  • #validate - list of custom validation functions to be passed;
  • #validation_arguments - arguments for field validation;
  • #value - used to set values ​​that the user cannot edit;
  • #value_callback - specifies the name of the custom values ​​function that implements how user input maps to the #value property of the element;
  • #weight - used to sort the list of form elements before output.

As you can see, the list of field properties is quite significant. It should be understood that each specific property can be used selectively - only for the field that supports it.

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.