vectorbross / vb_ai_widget_actions
Config action for recipes: adds an AI generate button to a field, only on bundles that have that field.
Package info
bitbucket.org/vectorbross/vb_ai_widget_actions
Type:drupal-module
pkg:composer/vectorbross/vb_ai_widget_actions
Requires
- drupal/ai: ^1.5
- drupal/core: ^11.2
- drupal/field_widget_actions: ^1.5
Requires (Dev)
None
Suggests
- drupal/maxlength: Shows a live character counter on the field when max_length is set.
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-12-03 21:57:21 UTC
README
Helper module for VB recipes. It provides one config action,
addAiGenerateButton, that adds an AI generate button to a field, but only
on the bundles that have that field.
Recipes cannot say "only if the content type has this field". This action does that check, so a recipe can target every form display with a wildcard and leave bundles without the field alone.
Used by
vb_ai_seo_meta
and
vb_ai_summary.
What it installs
| Module | Purpose |
|---|---|
ai_automators | Runs the prompt (part of drupal/ai) |
field_widget_actions | Shows the generate button under the field |
maxlength is optional. When it is enabled, the action can also add a
character counter.
What it configures
Nothing on its own. Enabling the module makes the config action available to recipes and adds the permission described under Permissions.
The config action, per bundle
- Skips the bundle if the field does not exist, is hidden on the form, or its field or widget type is not supported (plain text and formatted text fields, single and long).
- Creates an AI Automator
<entity_type>.<bundle>.<field>.defaultwith the "simple" LLM rule and workerfield_widget_actions, so it only runs on click. It uses the default chat provider. An existing automator is kept. - Adds the
automator_textfield widget action, unless the field already has an action for that automator. - Adds the Maxlength counter, unless the widget already has one.
Nothing existing is overwritten, so re-applying a recipe is safe.
Usage in a recipe
install:
- vb_ai_widget_actions
config:
actions:
core.entity_form_display.node.*.default:
addAiGenerateButton:
- field_name: field_seo_title
button_label: 'Generate SEO title'
prompt: 'Write an SEO title for: {{ context }}'
context_fields: [body, field_body]
max_length: 60
| Key | Required | Description |
|---|---|---|
field_name | yes | Machine name of the field that gets the button |
button_label | yes | Text on the button |
prompt | yes | Prompt for the AI. Must contain {{ context }} |
context_fields | no | Fields the AI reads; the first existing one wins. Falls back to the entity label |
max_length | no | Adds a Maxlength counter (soft limit) when Maxlength is enabled |
enable_refinement | no | Opens a dialog to refine the result before inserting. Default false |
Permissions
| Permission | Effect |
|---|---|
use ai generate buttons | See and click AI Automator buttons under form fields |
Field Widget Actions itself only checks whether the user may edit the
entity. This module hides every AI Automator button (any field widget
action provided by ai_automators) from users without the permission. The
button gets #access FALSE, so a crafted AJAX request cannot run the AI
either. The administrator role has every permission.
The recipes that use this module (vb_ai_seo_meta, vb_ai_summary) grant
the permission to the webmaster role.
Requirements
- Drupal 11.2+
drupal/ai1.5+ (ai_automators)drupal/field_widget_actions1.5+drupal/maxlength3.2+ (optional, for the counter)
Install
Normally you don't install this module yourself: a recipe such as
vb_ai_seo_meta requires it. To use it in your own recipe:
ddev composer require vectorbross/vb_ai_widget_actions
Verify
ddev drush pm:list --status=enabled --filter=vb_ai_widget_actions
Skipped fields (unsupported type or widget, hidden field) are logged in the
vb_ai_widget_actions channel in Recent log messages.
Tests
ddev exec vendor/bin/phpunit -c web/core web/modules/contrib/vb_ai_widget_actions/tests
License
GPL-2.0-or-later. See LICENSE.txt.