Hello,

I want to list a bunch of nodes using views and let the user change the state of that node right in the views.

So I made a View, added the proper fields, added Content: workflow and set the Formatter on Workflow.

First issue:
I thought now it should just work, the action buttons renders at the bottom of view but when you click on it, nothing happens, when I look at the code there's no Form tag in HTML. so that must be it.

Here's a screenshot (please don't mind the language)

Workflow field in Views

Second issue:
As you can see there are some extra commas rendered before the action buttons of workflow, when you inspect and look at the code you see the following:

<div class="views-field views-field-field-workflow">        
  <div class="field-content"><div class="workflow-form-container form-wrapper form-group" id="edit-workflow">
    <input type="hidden" name="workflow_hid" value="0">
    <input type="hidden" name="workflow_comment" value="">
</div>, 
<input type="hidden" name="form_build_id" value="form-mnuhUyxXv7TQz984BCxTsI7a1VvIsaTrKAcJSUQU8-Q">
, <input type="hidden" name="form_token" value="4GroanwNqYhS-EEKUj3meTEdGazIWidiPzrnJkAPe9U">
, <input type="hidden" name="form_id" value="workflow_transition_form_node_6_51">
    , <div class="form-actions form-wrapper form-group" id="edit-actions">
  <button class="form-save-default-button btn btn-default form-submit" id="edit-workflow-5" name="op" value="فروخته شد" type="submit">فروخته شد</button>
<button class="btn btn-default form-submit" id="edit-workflow-2" name="op" value="غیرفعال" type="submit">غیرفعال</button>
<button class="btn btn-danger form-submit" id="edit-workflow-3" name="op" value="حذف آگهی" type="submit">حذف آگهی</button>
<button class="btn btn-default form-submit" id="edit-workflow-4" name="op" value="انتشار" type="submit">انتشار</button>
    </div>
  </div>  
</div>

Which I assume is the separator set for workflow comment, label, current state and etc in code which when the user doesn't have the permission leave it as just a ","

Third Issue:
Well I ended up using VBO to make the action buttons to work, I added Bulk operations: Content field, to the views, excluded it from display, and checked Change workflow state of post to new state as the bulk operation and it ended up working in a weird way!

  • I'd like to know why it's not possible to just render Content: workflow as a form so it doesn't require the VBO to finish the job.
  • What are those extra Commas

Thanks a million for your time and efforts to save us the noobs, Johnv.

CommentFileSizeAuthor
#2 workflow-views.jpg114.83 KBdoxigo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

doxigo’s picture

Issue summary: View changes
doxigo’s picture

Issue summary: View changes
FileSize
114.83 KB
johnv’s picture

ad 1) Indeed, it should just work. if not, perhaps it went broken in the last version(s).
ad 2) the comma's in the Views Formatter are indeed there. The formatter on a 'normal' Node View or Node Form are OK. I do know that the comma's are there, but don't know how to get rid of them :-( I was hoping for the crowd to solve this puzzle.
ad 3) need to test this.

doxigo’s picture

Thanks John for the quick respond, so is there anyway to make sure that the first issue works ? I tested it against the latest stable version as well, still the same problem.

second issue is just weird!

third one is just a workaround I guess to get a Form tag in code.

I try to look into this on my own as well, I keep you updated if I end up with any solutions.

Thanks.

doxigo’s picture

I end up with jQuery to clear out the Commas:

  $('.views-field-field-workflow').each(function() {
    var text = $(this).html();
    $(this).html(text.replace(/, /g, ""));
  });
});

as for lack of form tag in Content: workflow field in views, no solutions yet!

johnv’s picture

doxigo’s picture

No I doubt it, I will use that to help me theme it easier, but it's not related to my issues unfortunately.

johnv’s picture

Component: User interface » Views
ph7’s picture

First issue:
I thought now it should just work, the action buttons renders at the bottom of view but when you click on it, nothing happens, when I look at the code there's no Form tag in HTML. so that must be it.

I experienced the same thing.

In my use case I want to include entityform fields in a workflow. I am able to change workflow states via the entityform submission page, but views gives me more out-of-the-box flexibility. In case of the entityform submission page the workflow widget is wrapped in a form element. Not so with views. Ergo, I'm unable to change workflow states in a view.

I found this post on how to programmatically add form elements to views.
I will further explore this in an effort to glue together these awesome modules.

ph7’s picture

Got it!

I noticed that the approach in the post as described in #9 is already implemented in the workflow_views module, so I turned my attention back to views configuration.

I had not previously noticed that entityform provides a field template setting under Configure Field > Style settings. When I ticked this option I was able to change the workflow state from views! So, changing workflow states from views should work if the 'source module' provides a views form template.

adamtong’s picture

i have same issue too! any solution for 1 and 2?

adamtong’s picture

oh...#10 is fixed my issue..just notice it

johnv’s picture

Status: Active » Fixed

I quess this is fixed.
If not, please open an issue for each problem separately.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

johnv’s picture

Status: Closed (fixed) » Closed (works as designed)