field_states
Field States module is base on state machine module. Unlike the standard state machine module, Field States offers an extended feature set. With this module, you have the flexibility to define a list of states, and within your field settings, you can easily specify transitions. This process becomes even more user-friendly, as you can conveniently copy and paste configurations directly from your workflow YAML files.
Field States uses library mermaid.js for visualizing your state machine, making it easy to understand and manage your states and transitions. Moreover, in the field formatter, you have the added convenience of selecting transitions effortlessly, enhancing your overall workflow management experience.
There are state machine editor. you can draw and config transitions (support only bootstrap 5 theme), It will create a state machine directly and not via yml configuration.
How to work
- Add field States transitions
- Fill all state in field storage (it looks like list string)
- set transitions in field settings (Yaml format)
- label: Transition Button Name
- from: [Multi states] # The states from which this transition is allowed
- to: state # The state to which the field should transition
- role: The role name that can see the transition button
- permission: Permission can see button
- group: Group id
- guard: Guard Plugin ID in Your Custom Module (method allowed) #
- workflow: [Multi workflow id] in your custom module (Pre-transitions method action)# Custom workflow logic if needed
- action: [Multi action id] in your custom module (Post-transitions method execute)# Custom action logic if needed
- extra: True|False
In case of you don't want to show extra field
guard: create custom/your_module/src/Plugin/Guard/CustomGuardPlugin.php
workflow: create custom/your_module/src/Plugin/Workflow/CustomWorkflowPlugin.php
action: create custom/your_module/src/Plugin/Action/CustomWorkflowPlugin.php
you can see exemple in module.
Extra field: In case you want to submit with a certain field, you can choose this field option. For example, when you want users to leave comments when changing status
History field: support double field, triple field, json table field
The Field State module for Drupal manages state machine transitions with a seamless process. To display the button, the module first verifies the [role], if it defines in field setting, ensuring it matches the [permission] if it defines in field setting. After that it will run [guard] to check. When the state transition button is pressed, the module triggers the execution of the [workflow]->action(), you can cutomize your logic before entity save. 'Cos this methode uses reference variable &$transitions. The module then saves the updated state to entity. It proceeds [action]->execute().This comprehensive sequence ensures smooth and flexible handling of state transitions in the Drupal environment.
Do you like this module? Show your appreciation by buying me ☕.