So, instead of simply having the option to turn on or off a comment field with each workflow status update, I think it would be ideal to be able to setup fields for each workflow so that we could have values for check boxes, signatures, agent name, approval codes, confirmation #'s, etc. (as well as comment fields) stored with each workflow update. Of course this would also require the workflow history records to become entities, but that probably wouldn't be a bad thing.
Whether or not there's eventually some integration between Workflow, Workbench Moderation, State Machine, etc., I thought it would be good to have this issue here in the Workflow module issue queue.
Status for D7-version (updated up to #35):
- Patch #13 --> #29 --> #30 --> #35
- Remarks in #27, #28
Status for D8-version (updated up to #35):
- #18: now supports Fieldable Workflow Transitions.
- #18: limitation: Not on the widget, only on the form (Block and the History tab)
- #18: limitation: Fields are added, but when editing a Transition, the added field cannot be changed.
- #18: todo: baseField definitions should be used, so you do not need to define them in the element.
- #18: todo: the WorkflowTransitionElement should be used.
- #26: adds the fieldability to the Workflow Widget and Workflow Form.
- #26: It still doesn't work for scheduled transitions.
Comment | File | Size | Author |
---|---|---|---|
#35 | workflow_save_fieldable_transition_D7-1559680-35.patch | 1.02 KB | johnv |
Comments
Comment #1
NancyDruThis sounds like it would be a prerequisite to any chance of moving into core, so I like the idea. Have you done any work on this?
Comment #2
NancyDruSee #2019345: Create a 'Workflow Field' with Widget, Formatter, Fieldtype
Comment #3
johnvSetting this as active again, since the next task on my list is to make workflow_node_history compliant with Field API.
This includes implementing an accompanying class WorkflowExecutedTransition / WorkflowHistoricTransition / WorkflowTransitionHistory (inspirational comments requested!) .
It is above my competencies to make a fieldable entity out of it, but you can build upon this.
@videographics, I invite you to test the new Workflow Field submodule!
Comment #4
johnv@videographics,
adding a new field to a transition would automatically add a new field to the Workflow form? If so, how?
Comment #5
johnvIn the meantime 3 OO-classes have been introduces, localizing Workflow, State and Transition. Now, Entity metadata wrappers can be contructed. Patches are welcome!
Comment #6
johnv"Changed Transitions into Entity. Views support enabled." is committed here.
The WorkflowScheduledTransition is crippled, since is does not have an ID.
You can now make Views of the entities. Relationships are still to do.
Next stop: adding view modes, so each of the following can have its own settings:
- node view
- tab page
- vbo page
Comment #7
johnvAdding it to the new META issue.
This would include all 3 types of Transitions (?)
- ConfigTransition
- ScheduledTransition
- EntityTransition
Should they be bundle of the sma 'abstract' Transition entity? ATM the ScheduledTransition inherits from EntityTransition.
Comment #8
johnvComment #10
johnvThis first commit adds fieldability to WorkflowTransition via the Workflow Admin UI pages.
It still doesn't save fields, and needs:
- adding function defaultUri() , e.g., /node/15/workflow/%workflow_transition (for every entity_type)
- uncommenting function call to field_attach_form('WorkflowTransition', $transition, $element['workflow'], $form_state);
- moving the 'edit comment' Views link into this form.
- testing the new code for non-entity pages: // - the VBO action form; // - the Advance Action form on admin/config/system/actions;
- will this work for scheduled transitions?
- adding a WorkflowTransitionUIController, if this reduces code.
Comment #12
johnvWith the adjacent patch, the WorkflowTransition objects are now fieldable!
Also, the Comment, TargetState and SchedulingInfo are now exposed as extra-fields, so you can move them around.
However, in the submit-function, a new Transtion is created and saved, without taking into consideration the fieldability. So every field has value 0. :-(
Comment #13
johnvAttached file is an attempt to save the attached fields..
Comment #14
johnvTodo: The extra_fields and the attached fields are not shown on the form, when it is exposed in a Advance Action or VBO action.
Comment #15
johnvIn D8, the following line must be activated:
[EDIT] which is done in #17.
Comment #18
johnvThe D8-version now supports Fieldable Workflow Transitions.
- limitation: Not on the widget, only on the form (Block and the History tab)
- limitation: Fields are added, but when editing a Transition, the added field cannot be changed.
- todo: baseField definitions should be used, so you do not need to define them in the element.
- todo: the WorkflowTransitionElement should be used.
Comment #21
johnvSee #1559680: Make Transitions fieldable entities
Comment #23
johnvComment #26
johnvAbove commit adds the fieldability to the Workflow Widget and Workflow Form.
It still doesn't work for scheduled transitions.
Comment #27
bohemier CreditAttribution: bohemier as a volunteer commentedI tried patch in #13 and it does save the fields. That's a good start, thanks johnv.
Comment #28
ericniaina CreditAttribution: ericniaina commentedI'm Using the patch and it seems to work but not on all field type.
I've tried on entity reference field and then I got Incorrect integer value because it's using raw value from $form_state['input']
Temporary change $form_state['input'] to $form_state['values']; on line 563 on the version 7.x-2.8 seems to fix my issue.
Comment #29
nicola85 CreditAttribution: nicola85 commentedComment #30
nicola85 CreditAttribution: nicola85 commentedComment #31
johnvComment #32
3ssom CreditAttribution: 3ssom as a volunteer and at Ministry Of Housing commentedHello,
This patch is working fine when adding values to cutom fields but it has some issues:
Thanx
Comment #33
johnvComment #34
mithenks CreditAttribution: mithenks at bmeme commentedFor what I understand, the patch is related to 7.x version.
Why is the issue referring to 8.x-1.x-dev?
Comment #35
johnvAttached patch is exactly the same as #30, only states the Version D7 in the file name.
@mithenks: generally, feature requests go from one version to the next. See #10 and #26. New features are then backported to a previous version.
Comment #36
johnvSetting this back to D7 for thos who are interested. D8 is now working. If anything is not working for D8, please open a new issue.
Comment #37
scoff CreditAttribution: scoff commentedD7 version with #35 works, kind of
Simple text field — I can add it, it gets stored when I create a new transition and I can *see* it with "edit comment" link (workflow_transition//edit). I can't change it though it just stays the same.
date field (or unix timestamp) produces this when I add a new transition
PDOException: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'field_date_value' at row 1: INSERT INTO {field_data_field_date} (entity_type, entity_id, revision_id, bundle, delta, language, field_date_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => WorkflowTransition [:db_insert_placeholder_1] => 11 [:db_insert_placeholder_2] => 11 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 2017-11-27 20:15 ) в функции field_sql_storage_field_storage_write()
nothing on change if the date was empty it just stays empty
Comment #38
totolearn CreditAttribution: totolearn commentedAny update on this issue? I applied the #35 patch. But there is still errors coming.
Here is what I got from different tries.
I can confirm that the workflow attached fields can be savd for text and link fields. But for list (text) and date field with time both are not saved in updating or adding new transition.
For the date field, when using date and time by popup calendar, the placeholder divided by two, ie. placeholder_6_0 (for date) and placeholder_6_1 (for time) and create SQL field mis-matching value error (field treat date/time as one field, but value placeholder passing two values).
In the testing, I wondered that the patch inside the foreach need to detect the proper field value to write. For list (text) field, it should write the field_name_value and for the date/time field, it should combine date time as one string to pass to SQL.
+ foreach($field_list as $transition_field_name => $bundles) {
+ if (isset($bundles['bundles'][$transition_type])) {
+ $transition->{$transition_field_name} = $items[0]['workflow'][$transition_field_name];
+ }
But, I am not good enough to find out the coding syntax for this.
Anyone?
Comment #39
singampalli CreditAttribution: singampalli commentedHI i am working on Drupal 7 , I have applied this patch. Its working well for textfields which are added in workflow. But I have added one noderefernce field. Its data is not getting saved into db.. Please help
Comment #40
strelkovandreyvalerievich#39 +1 I need entity reference, but website going down