Placement of Workflow settings on the node/add form

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by nonprofit on May 13, 2009 at 3:59pm

Hi, First off, thanks to everyone who contributed to this module; it's great.

We've got Workflow up and running and it's working very well. We've hit a minor snag (which happens to be of great concern to the client) and it's my job to fix the problem.

We've applied Workflow to two content types;

Content Type A has the states:
draft
submitted
published
in-process
closed

Content Type B has the states:
draft
submitted
publish
expired

Content Type A's workflow sits at the top of the /node/add/[type] page and Type B's is much further down on its submission form. There are six developers working away on this site, so I'm sure Workflow is simply responding to a setting somebody set somewhere; but everyone on the team is denying involvement.

Any guidance as to how I can determine the placement of the Workflow settings on the node/add form would be greatly appreciated.

Thanks!

-NP

Categories:

Comments

Dear NonProfit,

I had the same issue you're describing. It seemed to me that the Workflow section appeared at a particular part of the page and could simply end up in the middle of a bunch of fields if there were a lot of fields on the page. To account for this, I have a site-specific module that I called "form_alterations". Here's the code that you'd need from the .module file:

/**
* Implementation of hook_form_alter().
*
* This lets you make changes to any form in the site. You can alter, remove
* or add form elements. You can also alter the validation and submission
* behavior. The name will always be modulename_form_alter.
*/
function form_alterations_form_alter(&$form, $form_state, $form_id) {
// Normally a switch is used because you may want to alter more than
// one form and it is easy to add a new case for each form.
switch ($form_id) {
// This is our form ID.
case 'specialization_node_form':
case 'version_node_form':
// Adjust workflow form weight.
if ($form['workflow']) {
$form['workflow']['#weight'] = 28;
}
break;
}
}

Mark W. Jarrell
Manager of Web Services
Jones Knowledge Integration Group, Inc.
http://fleetthought.com
http://www.jones.com
http://www.jonesdifference.com
http://www.jiu.edu
Twitter: attheshow

Mark W. Jarrell
Online Applications Developer
Richland Library
http://www.richlandlibrary.com
http://fleetthought.com
Twitter: attheshow

Thanks!

Posted by nonprofit on May 13, 2009 at 6:54pm

Thanks, Mark. I'll check this out.

Cool.

Posted by owntheweb on January 26, 2010 at 3:52pm

This worked for me. THANK YOU for posting, Mark. To clarify for other newish users such as myself, if placing the workflow piece at the bottom of a 'product_service' node type form, the php is going to look like this:

/**
* Implementation of hook_form_alter().

This lets you make changes to any form in the site. You can alter, remove
* or add form elements. You can also alter the validation and submission
* behavior. The name will always be modulename_form_alter.
*/
function form_alterations_form_alter(&$form, $form_state, $form_id) {
// Normally a switch is used because you may want to alter more than
// one form and it is easy to add a new case for each form.
switch ($form_id) {
// This is our form ID.
case 'product_service_node_form':
// Adjust workflow form weight.
if ($form['workflow']) {
$form['workflow']['#weight'] = 28;
}
break;
}
}

I forgot to add the '_node_form' part, causing some confusion when getting started.

Best regards,

Chris

Worlds to explore. Worlds to create.
Blog: http://www.christopherstevens.cc/blog
Twitter: http://www.twitter.com/owntheweb

Workflow

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week

AltStyle によって変換されたページ (->オリジナル) /