Forms Steps

Provides a UI to create multi-step form workflows using entity form modes, enabling quick and configurable multistep forms in Drupal.

forms_steps
810 sites
75
drupal.org

インストール

Drupal 11, 10, 9, 8 v8.x-1.7
composer require 'drupal/forms_steps:8.x-1.7'

概要

Forms Stepsは、サイト管理者がコードを書かずにマルチステップフォームワークフローを作成できる強力なモジュールです。Drupalのエンティティフォームモードを活用して、エンティティの作成・編集を複数の連続したページに分割します。

このモジュールは「Forms Steps」と呼ばれる設定エンティティを導入し、完全なワークフローを定義します。これには、ステップ(それぞれがエンティティタイプ、バンドル、フォームモードを指定)、視覚的なプログレスバー表示用のプログレスステップ、完了後の動作を定義するリダイレクトポリシーが含まれます。

各ワークフローインスタンスは一意のUUID(instance_id)で追跡され、ユーザーはデータの一貫性を保ちながらステップ間を移動できます。モジュールは各ステップURLの動的ルートを自動的に作成し、ページ上の任意の場所に配置できるプログレスバーブロックを提供します。

Forms Stepsはまた、ユーザーがステップ間を移動する際にイベントを発火させ、開発者は登録後の自動ユーザーログインやデータ検証などのカスタムロジックを実装できます。

Features

  • コーディング不要で直感的な管理UIからマルチステップフォームワークフローを作成
  • あらゆるフィールド可能なエンティティタイプ(Node、User、Taxonomy、カスタムエンティティ)をサポート
  • 既存のDrupalフォームモードを活用して各ステップで異なるフィールドを表示
  • ワークフローの継続性のためのUUIDベースのインスタンス追跡を備えた動的ルート生成
  • カスタマイズ可能なステップリンクと表示制御を備えた設定可能なプログレスバーブロック
  • ステップごとにカスタマイズ可能なボタンラベル(送信、キャンセル、削除、前へ)
  • ワークフロー内での後方ナビゲーション用の「前へ」ボタンサポート
  • ワークフロー完了後の複数のリダイレクトポリシー(内部パス、外部URL、ルート、エンティティ表示)
  • ステップ遷移時のカスタムロジック用のStepChangeEvent
  • 既存エンティティをワークフローインスタンスにインポートするためのDrushコマンド
  • データベースバックエンドの永続化によるワークフローインスタンス管理
  • ソースエンティティ削除時のワークフローインスタンスの自動クリーンアップ
  • セキュリティを考慮した複数ステップにわたるユーザーアカウント作成のサポート
  • 設定時のステップページでの管理テーマサポート

Use Cases

Multi-step Node Creation

Create a content type with many fields and split them across multiple pages. For example, a job application form could have Step 1 for personal information, Step 2 for work experience, Step 3 for education, and Step 4 for document uploads. Each step shows only relevant fields using form modes.

User Registration Wizard

Split user registration into multiple steps: basic account info, profile details, and preferences. Use the StepChangeEvent to automatically log in the user after the first step, allowing subsequent steps to update their profile. Configure the final step to redirect to the user's profile page.

Order/Checkout Process

Create a multi-step checkout flow for a custom commerce solution. Step 1 collects cart items, Step 2 handles shipping information, Step 3 manages payment details, and Step 4 shows confirmation. The progress bar block helps users track their position in the process.

Survey or Quiz Application

Build complex surveys with multiple pages of questions. Each page (step) can display different fields or question groups. Progress steps show users how far they've progressed through the survey, with optional links to return to previous sections.

Onboarding Workflow

Guide new users through a setup process after registration. Each step collects different information: profile setup, notification preferences, tutorial completion. Use the redirection policy to send users to the dashboard after completing all steps.

Content Import with Existing Data

Use the drush command to import existing content into a workflow. For example, migrate legacy content into a new multi-step editing workflow by attaching existing nodes to specific workflow steps.

Tips

  • Create dedicated form modes for each step showing only the relevant fields for that part of the workflow
  • Use the Previous button feature to allow users to go back and review/edit earlier steps
  • Configure the redirection policy to 'Current Entity' to show users their completed content after the final step
  • Place the progress bar block in a prominent location and style it with CSS classes (previous-step, active, next-step)
  • For user registration workflows, always have the first step create the user and subsequent steps update the profile
  • Use the StepChangeEvent to implement custom validation, notifications, or data manipulation between steps
  • Export Forms Steps configurations to sync workflows across environments using Configuration Management
  • Enable 'Show links only if concerning steps have been saved' to prevent users from skipping steps via progress bar links
  • Test workflows with both new entities and existing entities (via drush command) to ensure proper behavior

Technical Details

Admin Pages 7
Forms Steps /admin/config/workflow/forms_steps

Main administration page listing all configured Forms Steps workflows. From here you can add, edit, delete workflows, and view workflow instances.

Add a Forms Steps /admin/config/workflow/forms_steps/add

Create a new Forms Steps workflow by providing a label, machine name, and optional description.

Edit Forms Steps /admin/config/workflow/forms_steps/edit/{forms_steps}

Configure all aspects of a Forms Steps workflow including steps, progress bar, and redirection settings.

Add Step /admin/config/workflow/forms_steps/{forms_steps}/add_step

Add a new step to the Forms Steps workflow by configuring entity type, bundle, form mode, URL, and button settings.

Add Progress Step /admin/config/workflow/forms_steps/{forms_steps}/add_progress_step

Add a progress step for the visual progress bar indicating workflow progression.

Workflow Instance List /admin/config/workflow/forms_steps/workflows/list

View all workflow instances that have been created, showing the workflow tracking data for each multi-step form session.

Forms Steps Settings /admin/config/workflow/forms_steps/settings

Global settings for the Forms Steps module.

権限 2
Administer Forms Steps

Administer all Forms Steps configurations and settings. Required to create, edit, and delete workflows.

View Workflow Instances

Access to view the workflow instances list showing all multi-step form sessions.

Hooks 6
hook_form_alter

Used internally by Forms Steps to intercept forms on Forms Steps routes and add step navigation handling.

hook_entity_type_alter

Automatically registers form classes for entity form modes used in Forms Steps workflows.

hook_entity_insert

Creates workflow tracking records when entities are created within a Forms Steps workflow.

hook_entity_presave

Updates workflow tracking records when entities are updated within a Forms Steps workflow.

hook_entity_predelete

Automatically deletes workflow instances when the source entity is deleted.

hook_theme

Defines the item_list__forms_steps theme hook for progress bar rendering.

Drush Commands 1
drush forms_steps:attach-entity

Attach an existing entity to a Forms Steps workflow instance. Useful for importing existing content into multi-step workflows or programmatically linking entities to workflows.

Troubleshooting 6
Form mode class missing error

Some entity types (like User) don't have default form classes for custom form modes. Implement hook_entity_type_alter() in a custom module to assign a form class: $entity_types['user']->setFormClass('my_form_mode', 'Drupal\user\ProfileForm');

HTTP 404 Not Found on step page

Ensure the form mode is enabled for the selected bundle at Administration > Structure > [Entity Type] > Manage form display. Clear caches after adding new form modes.

Progress bar not appearing

Verify that progress steps are configured for the workflow and that the progress bar block is placed in a visible region via Administration > Structure > Block layout. The block only renders on Forms Steps routes.

User registration fails on subsequent steps

For anonymous user registration across multiple steps, either enable automatic login (disable email verification in account settings) or implement a StepChangeEvent subscriber to log in the user after the first step.

Workflow instance not found error

This occurs when accessing a step with an invalid instance_id. Ensure users follow the workflow from the first step, or use the drush command to attach existing entities to workflow instances.

Steps not saving correct entity

Each step must use the same entity type and bundle if editing a single entity across steps. Different entity types/bundles in steps create separate entities. Check step configuration for consistency.

Security Notes 5
  • The module respects Drupal's entity access system - users must have create/update permissions for the entity types used in steps
  • Anonymous user registration across multiple steps requires careful security consideration - the module cannot grant update permissions to anonymous users for entities they just created
  • For user registration workflows, consider using automatic login after the first step or requiring email verification
  • Workflow instance IDs are UUIDs passed in URLs - while not easily guessable, they do provide direct access to workflow state
  • The 'administer forms_steps' permission grants full control over workflow configurations - assign carefully