Problem/Motivation
Over in #2944308: Is it possible to set up some kind of workflow on form?, there was some discussion of webform workflows. Well, adding workflows_field and putting that field on a webform makes it so I have a workflow. Its simple. The only thing needed is to add field_permissions to hide it for certain roles and this patch here.
Without this patch, the field values aren't saved to any webform submission fields.
Proposed resolution
Land this patch.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 3002547-29.patch | 4.27 KB | jrockowitz |
| #28 | 3002547-28.patch | 3.68 KB | jrockowitz |
| #24 | webform-submission_values-3002547-24.patch | 3.07 KB | mrweiner |
| #21 | webform-submission_values-3002547-21.patch | 2.42 KB | devkinetic |
| #18 | webform-fieldable_webform_submissions-3002547-18-D8.patch | 2.95 KB | liam morland |
Comments
Comment #2
heddnComment #3
heddnLet's be accurate in the title.
Comment #5
jrockowitz commentedThis feels like a major change. I need to some time to wrap my head around this. Hopefully, people will help review this patch.
Comment #6
heddnAgreed about major change :)
And it looks like we'd have a way to go to get it done properly, based on the number of test failures. But... its something to consider and it just works really nicely for workflows so it is so tempting.
Comment #7
jrockowitz commentedMaybe you can use hook_entity_type_alter() to enable field support in a custom module.
We would still have to update the WebformSubmissionForm to properly set the field values.
Comment #8
heddn@jrockowitz for the fieldable UI, that's a pretty easy temporary hack against the webform submission entity. I hack it, add the fields, then remove it. No big deal to me.
For the webform submission form stuff, a patch in incoming. I'll remove the field_ui route stuff from it. As long as we get the form changes, I don't care that much about the field route.
Comment #9
heddnHere's this more properly looks for fields. But removes the field_ui base route annotation on the entity. If someone wants to add fields, they'll have to hack it.
Comment #10
jbrauer commentedRe-roll only
Comment #12
jbrauer commentedFIx re-roll
Comment #13
jbrauer commentedRe-roll patch without extra character jumping in.
Comment #14
solide-echt commentedThis is an interesting approach: combining workflow with webform makes for some very strong workflow automation. I'm trying to switch from a state_machine implementation for webforms to workflow. Could you shed some light as to how exactly the YAML structure should be for such a field? I have a workflow named 'review_workflow_submissions'. Inspected the config for a field with this workflow in a user object and tried the following:
But this is not rendering...
Comment #15
justkristin commentedI love this idea, and I hope it does what I need! I did have problems getting the patch to apply - hunks 1 and 4 were failing, no doubt because my knowledge of patch isn't good enough to tell it to be a bit more wobbly in matching lines... I figured I would give creating a patch for my current install a try - my first patch uploaded here at all! Please tell me what I have pooched.
I am, for the record, running D8.7.5 with Webform 8.x-1.3 in the Pantheon environment.
Thank you to everyone with more brains than me! :)
Comment #16
justkristin commentedSorry, all. Screwed up the filenames and paths. This should be better. :)
Comment #17
justkristin commentedThat wasn't it either. I am stymied. Sorry!
Comment #18
liam morlandRe-roll.
@justkristin: It doesn't look like your patches were generated using Git. That is why they don't work. They could be applied using
patch, but the automated system usesgit apply.Comment #19
mrweiner commentedCan anybody shed some light on how to actually attach the workflow field to a webform?
EDIT: Ah okay, so the first patch has the "field ui hack" that @heddn was referring to. That exposes a "manage fields" option under the "operations" links at /admin/structure/webform. Manually adding
* field_ui_base_route = "entity.webform.edit_form",back in adds that "manage fields" option where the workflow field can be added to the webform entity.That being said, I guess I'm a bit confused what the intended use of this patch is if one cannot actually add fields to the entity. In what situation would we need to check/save field values for a webform submission if an admin cannot add fields to the webform in the first place? Or maybe a better question is, why are we removing the field_ui stuff from the patch?
Also note that the permissions noted in the initial description are not included in these patches -- it's referring to the field permissions module.
Comment #20
mrweiner commentedSetting to "needs work" per above edit
Comment #21
devkinetic commentedI've re-rolled that patch against 6.x so work can continue on this.
EDIT: Not sure whats going on with the test suite.
Comment #22
mrweiner commented@devkinetic your patch doesn't look to be in the right format. How'd you generate it? It includes the following which I don't think should be there, unless something has changed with the patch system with recent updates?
Comment #23
devkinetic commented@mrweiner My file is a git am patch as outlined in the Advanced patch contributor guide Under step 6.4. That first link walks you through how to use this type of patch.
In my testing, this patch is working great in conjunction with the workflows_field module. Bravo!
Comment #24
mrweiner commentedPatch wouldn't apply for me either. Re-rolling + adding check to make sure that fieldManager exists in copyFormValuesToEntity(), as we were sometimes hitting "Error: Call to a member function getBaseFieldDefinitions() on null in Drupal\webform\WebformSubmissionForm->copyFormValuesToEntity() (line 530 of /var/www/html/modules/contrib/webform/src/WebformSubmissionForm.php)."
Comment #25
devkinetic commented@mrweiner I think your issue was my patch is for 6.x and your patch is for 5.x. #21 is for 6.x and #24 is for 5.x. I just tested again and both apply via composer-patches to their respective versions.
Comment #26
jrockowitz commentedI can see that this is not easy patch to write tests for but I would be okay with committing it. I would even be open to committing it to 8.x-5.x.
Can someone a roll an 8.x-5.x patch and I will handle the merge conflicts with 6.x?
Comment #27
jrockowitz commentedSwitching version to 8.x-5.x
Comment #28
jrockowitz commentedMinor tweaks to the patch. If all the test pass, I will commit it.
Comment #29
jrockowitz commentedComment #32
jrockowitz commentedComment #33
mrweiner commented@jrockowitz sorry to open this back up, but I just tried upgrading to 5.19 and updates to my workflows_field seem not to persist through save. Reverting back to 5.18 with patch #24 fixes the issue. #29 and #24 do look quite similar so not sure what might have happened. Perhaps another Webform update from 5.18 to 5.19 may have affected this?
Comment #34
mrweiner commentedWhoops, didn't realize this was only in the dev branch atm -- thought it was released.
Comment #36
maxwellkeeble commentedHoping not to reopen ticket, but for future reference if anyone visits this ticket and wants to integrate with workflows_field, this summarises what I followed based on the mentions above, now that the patch is no longer required.
* field_ui_base_route = "entity.webform.edit_form",beforein annotation
This does not seem to:
Comment #37
devkinetic commented@maxwellkeeble This looks to be correct. My experience has been similar. It is definitely a process to integrate the field, but it can be done. Thank you very much for laying it all out there.
Comment #38
NewZeal commentedI have got this working rather easily by doing the following:
1. Implement the following hook in my custom module and clear the cache:
2. With Comment module enabled, go to administer comment types: admin/structure/comment and add a comment type that targets webform submissions.
3. Go to webform administration page: admin/structure/webform and click on the Operations dropdown for the webform you wish to add comments to. You should now find a Manage Fields link.
4. Click on Manage Fields and add a comment field of the type you just created.
There you have it! Comments.
Comment #39
jrochate commentedDo you have any idea how we could Duplicate or Clone a webform with a field added via "Manage Fields" using the above tips?
I was able to add a field and use it on the submissions, but when I build a new webform based on a duplication or cloning, the custom "Managed Fields" don't get copied. I have to go again to "manage fields" on the new webform and reuse the field.
Could that be automated based on duplication? Ideas, tips?