Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
when I hide the field in my node form, the state value is not saved in DB in the node__field_my_field table.
To reproduce :
- Add a workflow
- Add some state
- Adjust transition and access
- Add a field State to your content type Article
- Go to /admin/structure/types/manage/article/form-display and choose hide to your field State
- Add a new article
I don't find where it come from in the code, but I can help, if you can explain me where I can find the code with the Widget field
Comment | File | Size | Author |
---|---|---|---|
#6 | workflow-2724107-5.patch | 1.01 KB | willeaton |
#5 | workflow-2724107-5.diff | 1.01 KB | willeaton |
Comments
Comment #2
johnvThis is how the module works at the moment. The 'Hidden' widget (added by core) does not by default call the Workflow code. Perhaps this will be corrected some time in the future.
Comment #3
johnvThe functions FieldItemBase::preSave() and postSave() are called, when the Hidden widget is choosen, but only if the field already exists on the entity.
The following Core issues exist:
#2159951: Allow - Hidden - as a default widget type
#2060705: Remove the 'hidden widget' plugin, it is actually never used
#2378947: Hiding a field using form modes should not remove it from the form object
Comment #4
johnvI located an error in (the call to) WorkflowManager::executeTransitionsOfEntity, in below code.
We could change something there, or in the calling code. I just added the line with continue, but it causes that the entity is created without any field value.
Comment #5
willeaton CreditAttribution: willeaton commentedHi, what about this solution? I attach a patch which now does not throw an error when saving an a new custom entity entry which has the workflow field hidden (which is normal for me as we have the workflow tab). The entity is already loaded and the field is already known so I just took advantage of it. Maybe this might fail for a Node entity though...
Comment #6
willeaton CreditAttribution: willeaton commentedAdded with correct file extension
Comment #7
johnvComment #9
johnvThanks, committed as-is.
In the mean time, we are working on D9. It seems that the Hidden widget does not exist anymore.