Problem/Motivation
Can comments, scheduling etc. be switched on/off, depending on from/to state and user role?
Case #4: I need to be able to NOT allow comments on a post until/unless it is in a certain state. Typical case is pre-published states - wouldn't want people (i think actually it is just the creator, but still) posting comments until it reaches published state
Case #15: I have workflow field on a task node. A supervisor can create tasks for users and can set it to pending approval but only a mderator can approve/reject these tasks. However, if the moderator rejects a task, only then I want to restrict him/her to enter workflow comment so that it will help other mods to track why a task was rejected. It can be applied to other workflows as well.
Steps to reproduce
Proposed resolution
#10: Rules, trigger on the state to toggle comment on / comment off on the node.
#14: Disable comments in nodes depingnig on specific taxonomy terms
#16: The Webform Workflow project has such a feature. We can borrow from that.
#22: The following workflow-specific modules do the same (which should work with workflow_node):
- https://www.drupal.org/project/workflow_fields
- https://www.drupal.org/project/wf_required_fields
#24: The following generic modules do the same (which would work with workflow_field):
- https://www.drupal.org/project/conditional_fields
- https://www.drupal.org/project/field_conditional_state
#25: Join #2639372: Set entity fields to hidden/view/edit/required based upon workflow state for the D8-plans
#29: Allowing the requirement of a comment field to be granular to transition - not (only) to state.
Example Transition Configuration
Creation -> Draft | Not Required
Draft -> Review | Not Required
Review -> Reject | Required
Reject -> Review | Not Required
Review -> Approved | Not Required
#32: Actually a very valuable reason to have the widget is, e.g. for and application flow the button would be "Apply now" or submit which can be nicely controlled with workflow and transition lables. But not having this breaks this idea totally. I think it must always be shown.
#33: [...] on some states, the transition should happen with comments mandatory and on remaining states, the comment field itself should not be visible. (per state, or perhaps even per role.)
#35: Apparently, the one-state button is not wanted, when the comment is not visible: ""When a user does not have any more transitions available, the block "Workflow Transition form" contain a "Update workflow" button that, when pushed, does nothing. Could it be removed?
#36: "You do need the (options) widget to add comments when you are in an endstate. (That may be the end state for some users, but not for others.)
Use case 1: When the current user only has the "save" action available (ie the "same state" -> "same state" transition) the button for that action does not appear.
Use case 2: The normal comment form disappears when there are no transitions available for the current user. I got users who cant change the workflow state but they can react on comments.
#18: Since Drupal version D7.8 (hence, also in Drupal version 8.0), the following hooks appear:
hook_field_widget_form_alter, hook_field_widget_WIDGET_TYPE_form_alter
which are deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use hook_field_widget_single_element_form_alter instead.
This is far more easy then the already existing
hook_form_alter, hook_form_FORM_ID_alter, hook_form_BASE_FORM_ID_alter, since all relevant data is already at hand.
Remaining tasks
In the past, maintainer was not very sharp on the sue case of each contributor.
Standard WorkflowTranstiionForm is:
- with widget (select/radios/dropdown, but many contributors use special case of 'Actionbuttons'.
- with comment field - this may be hidden/optional/required as per rol, or state (=pre) or even transition (=post)
- with attached field - text, number or file upload (which needs special treatment, since it does not work out-of-the-box)
- #10: Add a script using Rules;
- #14, #16: Add functionality in code, borrowed from Webform Workflow;
- #18: provide a nice submodule implementing:
-- a UX/DX appending the workflow(_admin)_ui submodule
-- the hook_field_widget_WIDGET_TYPE_form_alter hook for widget 'workflow_default', using one of the hooks in workflow.api.php. You will also find a.o.:
-- hook_form_workflow_transition_form_alter(), hook_form_alter(), hook_field_attach_form()
Caveat: At the moment (version 7.x-2.5 and 8.x-1.x) , there is no uniform way for Widgets on Entity forms, and the Workflow Transition Form. The WTF does not call a widget, but adds an element. So we need hook_field_widget_WIDGET_TYPE_form_alter AND hook_form_workflow_transition_form_alter
This needs work.
User interface changes
API changes
Data model changes
#36: The following patch contains 2 changes: https://www.drupal.org/files/issues/workflow-button_not_available-259631...
-
// (If user has only 1 workflow option, there are no Action buttons.)
$options = $to_sid_widget['#options'] ?? [];
if (count($options) <= 1) {-
// The easiest case first: more then one option: always show form.
if ($count > 1) {return;}Original report by Flying Drupalist
Can states be given to comments?
Comments
Comment #1
Flying Drupalist commentedHi, I would really appreciate it if someone could help me. Thanks!
Comment #2
jvandyk commentedStates cannot be given to comments with the current version of workflow. But it is an interesting feature, and worth including in the future.
Comment #3
Flying Drupalist commentedThanks! :)
Comment #4
liquidcms commentednot sure what you are asking; but is it the same as this:
i need to be able to NOT allow comments on a post until/unless it is in a certain state - hard to believe that isn't here now; so maybe i am just missing it somewhere.
typical case is pre-published states - wouldn't want people (i think actually it is just the creator, but still) posting comments until it reaches published state
Comment #5
Encarte commentedSo, just like there are options to read or edit nodes for each state, there would be options to read or post comments for each state on the workflow settings...
Comment #6
stinky commentedI'm trying to do the same thing. I have a node with workflow permissions set to view only, but I want the viewer to be able to submit comments. Is this really not possible?
Comment #7
jvandyk commentedIt sounds like what you want is a trigger that runs an action when a workflow transitions happens; the action sets the node's comment settings. That is different than the feature requested in the original post.
Comment #8
hawleyal commentedsubscribing
Comment #9
cindyr commentedAnother vote here for allowing comments to be assigned to a state - certain roles have access to view/submit comments dependent on the state. Please?
Comment #10
Bastlynn commentedFor version 1 of this request: Comments are not nodes. Use node_comment and then yes.
For version 2 of this request: Rules, trigger on the state to toggle comment on / comment off on the node.
Comment #11
johnvre-assigning this feature request.
See the following issue for using hook_workflow to change the comment state. As Bastlynn stated, this can be achieved with Rules, too,
#895106: Extended workflow access: permission to post comments or edit specific cck fields.
Comment #12
matt.rad commented@johnv & Bastlynn: I would like to do this too. I have been looking around in Rules to see how to toggle the comment form on and off, but it is not apparent to me. Where will I find this? Thanks.
Comment #13
johnv@matt.rad, try the new hooks of version 2.5 . See workflow.api.php for new documentation.
Comment #14
matt.rad commentedFor others interested, this was the post that helped me figure out how to do this with Rules.
http://drupal.stackexchange.com/questions/13937/disable-comments-in-node...
Comment #15
najamfzl commentedI want a "conditional workflow comment" feature (see case below), not sure if this is what op wanted. If it isn't, do tell me so I can open another feature request. It would be great to have comment as a separate field so that it can be shown conditionally using Conditional Fields module. Please excuse me if it sound odd since I am strictly a mediocre site builder and know very little about code.
Case: I have workflow field on a task node. A supervisor can create tasks for users and can set it to pending approval but only a mderator can approve/reject these tasks. However, if the moderator rejects a task, only then I want to restrict him/her to enter workflow comment so that it will help other mods to track why a task was rejected. It can be applied to other workflows as well.
Comment #16
johnvReopening, since this keeps popping up.
The Webform Workflow project has such a feature. We can borrow from that.
Marking #2585055: Workflow Comment depending on State as duplicate.
Comment #17
johnvMore requirements for finer granularity:
See also
#2530986: comment required depending on role
#1176192: Workflow Access Extension
#2596591: Collaborate with Webform Workflow module webform_workflow
Comment #18
johnvSince Drupal version D7.8 (hence, also in Drupal version 8.0), the following hooks appear:
hook_field_widget_form_alter
hook_field_widget_WIDGET_TYPE_form_alter
This is far more easy then the already existing
hook_form_alter, hook_form_FORM_ID_alter, hook_form_BASE_FORM_ID_alter, since all relevant data is already at hand.
Volunteers may provide a submodule implementing:
- a nice UX/DX appending the workflow(_admin)_ui submodule
- the hook_field_widget_WIDGET_TYPE_form_alter() hook for widget 'workflow_default'.
At the moment (version 7.x-2.5 and 8.x-1.x) , there is no uniform way for Widgets on Entity forms, and the Workflow Transition Form. The WTF does not call a widget, but adds an element.
This needs work.
Comment #21
johnvComment #22
johnvClosing #696112: Make fields required/optional/hidden per workflow state as a duplicate, which gives the following supporting modules:
https://www.drupal.org/project/workflow_fields
https://www.drupal.org/project/wf_required_fields
Comment #23
johnvComment #24
johnvSince Drupal 7.14 and 8.0.0, the State API is available. It is used ins the following generic (not workflow-specific) contrib modules:
- https://www.drupal.org/project/conditional_fields
- https://www.drupal.org/project/field_conditional_state
In #2639372: Set entity fields to hidden/view/edit/required based upon workflow state , the plans for this functionality in D8 is discussed. Join that issue!
Comment #25
delacosta456 commentedhi
another possibility for the Case #4 can be done using the Fools Rules module
hope it will help
Comment #26
johnvComment #27
fishfree commented+1 pls.
Comment #28
johnvComment #29
johnvAdded info from #2616882: Make Comment Requirement Configurable per Transition:
Comment #30
johnvComment #31
johnvComment #32
johnvFrom #2948377: Do not hide widget when having only one option
Comment #33
johnvFrom #2850103: Display/hide/require the Comment subfield based on state
"I have a situation where on some states, the transition should happen with comments mandatory and on remaining states, the comment field itself should not be visible."
Comment #34
johnvComment #35
johnvFrom #2701119: WorkflowTransitionForm contains action "Update workflow" when no transitions are available to the user
"When a user does not have any more transitions available, the block "Workflow Transition form" contain a "Update workflow" button that, when pushed, does nothing. Could it be removed?
Comment #36
johnvComment #37
johnvComment #38
johnv