If a user can execute a transition on a node, he should be told which fields will be required for this transition to succeed. This is more user friendly than to complain after he tried.
On the workflow tab, drupal_set_message can be used for that. On node edit forms, an option is to append to $element['#description'] .
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | requiring-states-asterisk-207465-3.patch | 3.58 KB | gaëlg |
Comments
Comment #1
adshill commentedIf I understand, this means showing a required asterisk in red (*) next to each field required to get to the next workflow state. I would pay for this and I think its not so hard. $200 bounty for it if you contact me in the next 24 hours!
Comment #2
HairMachine commentedIf you comment out the entirety of the wf_required_fields_workflow hook function then this module appears to work a lot more like what I expected. What I had expected was, you selected which workflow states are set to have 'required' fields, and this means that the any content which is in that state requires those fields in order to be submitted. The default behaviour of the module, however, prevents the saving of a node if the *next* state has required fields that are not completed in the current state.
Removing the implementation of hook_workflow solved this issue for me, but I haven't tested it completely so do so with caution. It's also horribly bad practice of course, but I was in a hurry! :)
Comment #3
gaëlgThis patch works for my basic needs. If the field is not currently required but would be required in other workflow states, it displays an orange asterisk and the list of the states requiring the field.
It uses the #post-render attribute to alter the rendered content of the field. This is probably not so good to insert html tags next to the rendering, so if you see some better way of doing things, let me know.
I'm not very comfortable with Form API, it may not work for complex cases like fieldgroups.
Comment #4
mudd commentedAlso, if ever a role-base exemption is added (I tried cck_required_by_role but the magic is not happening for fields required by this module), then it would be nice if message for that next-state transition requirement is adjusted.
EDIT:
Really neat would be to disable those states in the workflow widget unless the field is populated.
I patched with #3, but I don't want to show the end users all of the approval states, so I removed implode(', ', $states) -- I'm still trying to figure out how to detect the next state in the workflow and use javascript to disable that workflow radio button...
Comment #5
gaëlgNext state detection seems to be done in this function.