It would be useful if the revisions functionality could be controlled per bean type, similar to how it can be controlled per content type - not all beans need revisions and it just adds UX confusion to mandate the fields be controlled per object.

Comments

nicolas bouteille’s picture

Title: Allow each bean type to control revisions » Enable / disable revisions per Bean Block type
Issue summary: View changes

How come an issue can just stay active for more than a year with no comment?

I am just starting to use Beans in order to make it simpler for end-users to deal with blocks and one of the first things I noticed is that revisioning can't be disabled and thus adds complexity in the interface!
I will be using the quick fix below for now but I definitely encourage you to go through with this feature request.
http://www.sagetree.com/sage-advice/zakiya-khabir/quick-fix-disable-bean...

pfrenssen’s picture

@Nicolas, patches are welcome.

damienmckenna’s picture

joelpittet’s picture

Started to give this a go but the patch was getting a bit too big and didn't feel like it was getting very far.

Quick fix caught my attention:

http://www.sagetree.com/blog/2013/05/quick-fix-disable-bean-revisions

function MYMODULE_form_bean_form_alter(&$form, &$form_state) {
  // Hide the revision checkbox.  
  $form['revision']['is_new_revision']['#type'] = 'hidden';
 
  // Make "Create new revision" off by default
  $form['revision']['is_new_revision']['#default_value'] = 0;
 
  // Hide the revision log field.
  $form['revision']['log']['#type'] = 'hidden';
}

This just hides it everywhere, which for the site I'm working on, works great.

rcodina’s picture

#4 works for me. Thanks!

jwilson3’s picture

#4 works, but it doesn't get rid of the "revisions" tab (next to view | edit tabs on /block/X/view page.

I combined #4 with the following for one wholesome solution:

/**
 * Implements hook_menu_alter().
 */
function MODULE_menu_alter(&$items) {
  // Disable revisions functionality from bean module.
  unset($items['block/%bean_delta/revisions']);
  unset($items['block/%bean_delta/revisions/%']);
  unset($items['block/%bean_delta/revisions/%/view']);
  unset($items['block/%bean_delta/revisions/%/edit']);
  unset($items['block/%bean_delta/revisions/%/set-active']);
  unset($items['block/%bean_delta/revisions/%/delete']);
}

If you need something not so drastic, such that certain roles can access the hidden tabs see this: https://www.drupal.org/node/483324#comment-2257606

O U T L A W’s picture

I'm trying to reproduce the node revision behaviour to the beans. The revision form is always accessible, and a new revision is created by default on bean creation. If you compile the log field without adding a new revision, the current revision log is updated. The field to set the current revision is never shown to users, and the new revisions are always set as current revision. And I've added the revision form and view mode form to a vertical tab.

This not allow users to enable/disable revision per bean type, but it sets to false the revision for all beans.

Sorry for my english. :)

/**
 * Implements hook_form_FORM_ID_alter()
 */
function hook_form_bean_form_alter(&$form, &$form_state, $form_id) {
  $form['additional_settings'] = array(
    '#type' => 'vertical_tabs',
    '#weight' => 99
  );

  $form['revision_information'] = array(
    '#type' => 'fieldset',
    '#title' => t('Revision information'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    'revision' => $form['revision'],
    '#group' => 'additional_settings'
  );

  $form['revision_information']['revision']['#access'] = TRUE;
  $form['revision_information']['revision']['is_new_revision']['#default_value'] = FALSE;
  $form['revision_information']['revision']['default_revision']['#default_value'] = TRUE;
  $form['revision_information']['revision']['default_revision']['#access'] = FALSE;
  /*
  $form['revision_information']['revision']['is_new_revision']['#states'] = array(
    'checked' => array(
      'textarea[name="log"]' => array(
        'empty' => FALSE
      )
    )
  );
  */

  $form['view_mode_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Manage display'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    'view_mode' => $form['view_mode'],
    '#group' => 'additional_settings'
  );

  unset($form['revision_information']['revision']['log']['#dependency']);
  unset($form['revision']);
  unset($form['view_mode']);
}

Node revisions have a #states that refers to textarea[name="log"], but I'm not sure if it is required or not... To my test on Beans it seems to make no difference.

I'm pretty new to Drupal, so please check my code. :)

damienmckenna’s picture

Status: Active » Closed (won't fix)

I don't think there's any benefit to this, if you want to disable revisions you can use hook_form_alter to disable the field on the form (#access => FALSE).