Helper fixes small annoyances in Drupal core and popular contrib modules, and gives developers a set of services and utilities for everyday module and site building work.
- Read the full documentation for every helper and the API reference.
- Submit bug reports and feature suggestions, or track changes, in the issue queue.
Requirements
This module requires Drupal 11.3 or later, or Drupal 12, and these libraries, which Composer installs with it:
The Drush commands need Drush 13 or later. Some helpers only apply when the module they work with is installed, such as Layout Builder, Views, Media or Translation Management Tool, but Helper doesn't require any of them.
Installation
Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
Configuration
Helper has no settings page. Each helper is turned on or off in the enabled mapping of the helper.settings configuration, for example with Drush:
drush config:set --input-format=yaml helper.settings enabled.core_form_novalidate true
Some helpers are on when Helper is installed, but stay off on sites that installed it before the helper was added, until they're turned on. See the documentation for each helper's default.
Highlights
- Better
#statesin forms. Conditions on multiple selects work, plus regular expression, exclusive or and textarea line conditions. - Smarter Views exposed filters. Show field filters only for the content types that have the field, clear filters when they're hidden, and hide selects with nothing to choose.
- Better Views cache hit rates. Views filtered by bundle are tagged with bundle list cache tags, such as
node_list:article, so saving a page no longer clears every view of articles. - Bulk forms that only offer what you can do. Actions the user can't perform are removed from Views bulk forms.
- Layout Builder conveniences. A Layout operation link that becomes the default operation in listings, and the featured action in the Navigation top bar, when an entity's layout is overridden or its default layout is empty. Inline blocks are kept out of default layouts.
- Developer APIs, such as
ContentEntityUpdaterfor batch updates of content in post-update and deploy hooks, and helpers for arrays, render elements, entities, views, menus, config and files.
Configurable helpers
These can each be turned on or off, as described in Configuration.
Forms and fields
core_states_conditions_fix: fixes and extends#statesconditions for multiple-select fields, and adds regular expression, exclusive or and textarea line conditions.core_form_novalidate: turns off HTML5 form validation.core_entity_reference_hide_empty: hides entity reference fields with nothing to select.core_text_long_textfield_widgets: single-line widget for formatted long text fields.core_text_textarea_widgets: textarea widgets for plain text fields.core_hide_text_format_help_single_format: hides text format help when only one format is allowed (Drupal before 11.4).core_hide_layout_providers: hides layouts from the listed modules.cacheable_binary_file_response: lets reverse proxies and CDNs cache public files that Drupal sends itself.redirect_entity_4xx_to_edit: sends editors to the edit form when viewing an entity gives a 403 or 404.
Views
views_exposed_states_bundle_filter_fields: shows field filters only for bundles that have the field.views_exposed_states_reset: clears exposed filters when#stateshides them.views_exposed_select_hide_empty: hides exposed selects with nothing to choose.views_cache_tags_bundles: bundle list cache tags for views filtered by bundle.views_filter_bulk_action_options: removes bulk actions the user can't perform.views_fix_sort_indicator_direction: shows the correct direction sort arrow on views tables in the listed themes and their sub-themes, by default Claro and Default Admin.
Layout Builder, media, menus and translation
layout_builder_entity_operation: adds a Layout operation link to entities that can override their layout.layout_builder_entity_operation_default_overridden: makes Layout the default operation in listings, and the featured action in the Navigation top bar, when the layout is overridden or the default layout is empty.layout_builder_inline_block_validation: prevents inline blocks in default layouts.media_oembed_iframe_title: adds atitleto oEmbed iframes for accessibility.menu_links_prefer_deepest: prefers the deepest menu link for an entity.navigation_create_links: adds media types and other entity types with an add form to the Navigation module's Create menu, all bundles in a drop-down or chosen ones as links.tmgmt_hide_if_not_multilingual: hides Translation Management until the site has a second language.
For developers
Much of Helper is a toolkit for writing modules, update hooks and site code.
Services
ContentEntityUpdater: updates content entities in batches from ahook_post_update_NAME()or Drush'shook_deploy_NAME(), withupdate()andupdateFieldPropertyValue(). Includes entities in the trash.
\Drupal::classResolver(ContentEntityUpdater::class) ->update($sandbox, 'taxonomy_term', function (TermInterface $term) { $term->setName(mb_strtolower($term->getName())); return TRUE; });Config: imports and re-exports config files, directories and modules, withimportModule(),importFile()andreExportModule().CurrentEntity: gets the entity of the current page withfromRouteMatch(), on any of its routes: canonical, edit, revisions, preview, Layout Builder and REST, falling back to Metatag'shook_metatag_route_entity(). Optionally limited to route names matching a pattern, and cached for the request.EntityHelper: checks entities and gets their state, withmatchesPath(),hasValue()andgetState().EntityType: works with bundles and entity options, withgetBundleOptions(),getEntityOptions(),accessBundles()andgetBundlesReferencingBundle().File: creates or reuses file entities, builds data URIs and checks whether a URI is public, withcreateOrReuseFromUri(),getDataUri()andisPublicUri().InstallProfile: switches the site's install profile, withswitch().LayoutBuilder: checks and sets entity layouts, withisEntityLayoutOverridden(),isLayoutEmpty()andsetEntityLayout().MediaHelper: gets a media item's file and allowed file extensions, withgetFile()andgetFileExtensions().Menu: builds menus from menu names, links and link fields, withbuildMenu(),buildLinkFieldAsMenu()andgetMenuLinkForEntity().PathautoHelper: checks whether an entity has an automatic alias, withhasAutomaticAlias().StringField: changes string and text fields that already have data, keeping it: their length withchangeLength(), to or from formatted text withchangeToText()andchangeFromText(), and to their long (unlimited length) types withchangeToLong().CustomField: changes Custom Field string subfields that already have data, keeping it: their length withchangeLength(), and tostring_longwithchangeStringToLong().TextFormat: changes the HTML tags and attributes a text format allows, withaddTag(),removeTag()andisTagAllowed().Theme: checks, sets and temporarily switches themes, withisActive(),switch()andswitchBack().ViewHelper: reads a view's bundle filters, withgetBundleFilters()andgetEntityBundlesFromFilter().
Static utilities
ArrayHelper: changes arrays while keeping their keys, withinsertAfterKey(),replaceKey(),addUniqueValue(),removeValue()andchunkEvenly().Field: finds duplicate values in a field, withgetDuplicateValues().Html: removes HTML comments, withremoveComments().Plugin: gets plugin managers and plugin options for forms, withgetManager()andgetOptions().RenderElement: changes render arrays, withattachLibrary(),attachHeader(),attachStyle(),mergeAccess(),wrap()andapplyToChildren().Utility: runs batches and other small tasks, withrunBatch(),runSandboxBatch(),registerUniqueShutdownFunction()andmatchString().
Plugins
- Date only field widget (
helper_timestamp_date): a date picker without a time for timestamp and created fields. - Entity select form element (
helper_entity_select): a select list of entities. - Node field block (
helper_node_field): shows a field of the current node in any block region. - Context rendered entity block (
helper_context_entity): shows the current entity in a chosen view mode. - Unique field values constraints (
UniqueFieldValuesandHelperEntityFieldUniqueValues): reject duplicate values in a field. - Helper Logging Mailer (
helper_logger): logs emails instead of sending them. - Tag based Views cache with bundle cache tags: used by the
views_cache_tags_bundleshelper.
Drush commands
entity:count: counts entities by bundle.entity:field:value,entity:field-type:value,entity:field:emptyandentity:field:minimum-values: find entities by their field values.entity:field:taxonomy: summarizes taxonomy term usage.redirects: summarizes redirects.install-profile:switch: switches the install profile.module:schema-version:get,set,deleteandcleanup: manage module schema versions, including leftovers from deleted modules.module:post-update:reset: lets a post-update hook run again.cache:clear librariesandcache:clear bootstrap: clear the library definitions and CSS/JS, or the bootstrap cache.
Data files
JsonFile, YamlFile and ComposerFile read and write JSON and YAML files, and the site's composer.json, with readData() and writeData(). They're meant for important files that are read often, even on every request:
- They can be used early, even in
settings.phpbefore Drupal has booted. - They cache the decoded contents until the file changes: in APCu through core's file cache before Drupal boots, and in a chained fast (APCu) cache bin after.
For example, to read a JSON file in settings.php:
$domains = (new \Drupal\helper\File\JsonFile($app_root . '/../domains.json'))->readData();
Twig
format_bytesfilter: formats a number of bytes as a readable size.file_data_uri()function: embeds a file as a data URI.
Other
is_multilingualroute requirement: limits a route to sites with more than one language.module_dependencyservice tag: removes a service when a module it needs isn't installed.- Sub-theme region inheritance from the base theme.
- Test traits with assertions for render elements and their cache metadata, file usage, and queues.
Project information
- Project categories: Administration tools, Content editing experience, Developer tools
1,990 sites report using this module
- Created by dave reid on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 2.x-dev updated 24 Oct 2026 at 07:13 UTC
Fixes fatal error when helper is included in modules during installer
Development version: 2.x-dev updated 24 Oct 2026 at 07:13 UTC
Development version: 8.x-1.x-dev updated 24 Oct 2026 at 03:41 UTC

