The Field Collection module does not support revisions. Yes there are lots of patches which are still under review. But what I want to do is create a module that on the node edit screen, queries the fields of the content type and removes the Revision Information tab (or disables the "Create new revision" checkbox) if the content type has one or more Field Collection fields. Any help on how which hook to use, how to query the fields of a node, and how to disable the revisions tab would be very helpful. This module needs to be applied to hundreds of sites.
Thanks to pcambra, here is my module:
function epc_no_revisions_for_fc_form_node_form_alter(&$form, $form_state) {
$collection_fields = field_read_fields(array('type' => 'field_collection'));
foreach($collection_fields as $FC){
if(isset($form['#node']->$FC['field_name'])){
$form['revision_information']['#access'] = FALSE;
drupal_set_message("This node cannot accept revisions because it contains the following Field Collection: " . $FC['field_name'],'status');
}
}
}
UPDATE:
The above module didn't handle a fresh node where the fields had not yet been set. So I revised it to first load all the fields in the database and see if any belong to the bundle (content type) in question:
function epc_no_revisions_for_fc_form_node_form_alter(&$form, $form_state) {
if(_epc_no_revisions_for_fc_test_for_fc($form['#node']->type)){
drupal_set_message("Please note: This node cannot accept revisions because it contains a Field Collection",'status');
$form['revision_information']['#access'] = FALSE;
}
}
function epc_no_revisions_for_fc_node_presave($node) {
if(_epc_no_revisions_for_fc_test_for_fc($node->type)){
if($node->revision == 1){
$node->revision = 0;
drupal_set_message("No revision was created because the content type contains a Field Collection",'status');
}
}
}
function _epc_no_revisions_for_fc_test_for_fc($node_type){
$fields = field_info_fields();
foreach($fields as $field){
if($field['type'] == 'field_collection'){
foreach(array_shift($field['bundles']) as $content_type){
if($node_type == $content_type){
return true;
}
}
}
}
return false;
}