I have been trying to set DS view modes at the node type level rather than at the individual node level. This is supposedly supported by 7.x-1.2. However, everytime I try to save the configuration on "admin/structure/cvm" I get the following error:

FieldException: Attempt to create an instance of a field field_cvm_cvm that doesn't exist or is currently inactive. in field_create_instance() (line 457 of /home/china/apache/www/nabto/modules/field/field.crud.inc).

The first time this happened was when I tried to add the basic page by clicking the appropriate checkbox. The next time I tried loading "admin/structure/cvm" I can now see the basic page view mode settings as a fieldset below the checkboxes. However, when I try to set the global contextual view modes within this fieldset, I once again get the same error message.

When I reload the page "admin/structure/cvm" I discover that the changes I had made to the basic page view mode settings have not been preserved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sherakama’s picture

Assigned: Unassigned » sherakama
Status: Active » Needs review

Based on your error I would assume that the module was not able to install correctly. Try re-installing the module and see if the error persists.

dman’s picture

I'm not getting an error, but I am finding that the global settings for a node type are not being retained when saving this form.

dman’s picture

Yeah, my settings weren't saved because the machine name of my content type had underscores and

      $xp = explode("_", $field_name);
      unset($xp[0]); // Dont need this.
      $content_type = $xp[1];

didn't respect that.

Prob not the same issue as the OP.
I'd better come up with a fix for that.

sherakama’s picture

Status: Needs review » Needs work

That was a bad oversight by me. I have changed the fieldname convention to use triple underscores. A bit of a bandaid solution until I can put some further thought into it. Check the dev branch for that code.

steven.wichers’s picture

I updated to version = "7.x-1.2-alpha1+1-dev" and now none of the view mode selections save -- those with or without multiple words. $values is empty in the submit handler.

victoriachan’s picture

Hi,

I've noticed an error in the fix, on line 185:

if (substr($field_name, 0, 11) == "cvmglobal___") {

It should be

if (substr($field_name, 0, 12) == "cvmglobal___") {

I'll attach a patch.

Thanks,
Victoria

grota’s picture

The patch above at #6 is a valid one, can we please get it merged upstream?

Frank Ralf’s picture

I get the same error as in the OP. Uninstalling and re-installing the module throws the following error:

PDOException: 
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: 
CREATE TABLE {field_data_field_cvm_cvm} ( `entity_type` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The entity type this data is attached to', `bundle` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` INT unsigned NULL DEFAULT NULL COMMENT 'The entity revision id this data is attached to, or NULL if the entity type is not versioned', `language` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'The language for this data item.', `delta` INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_cvm_cvm_view_mode` VARCHAR(255) NOT NULL COMMENT 'The view mode to use when context validates', `field_cvm_cvm_context` VARCHAR(255) NOT NULL COMMENT 'The context to authenticate against', PRIMARY KEY (`entity_type`, `entity_id`, `deleted`, `delta`, `language`), INDEX `entity_type` (`entity_type`), INDEX `bundle` (`bundle`), INDEX `deleted` (`deleted`), INDEX `entity_id` (`entity_id`), INDEX `revision_id` (`revision_id`), INDEX `language` (`language`), INDEX `field_cvm_cvm_view_mode` (`field_cvm_cvm_view_mode`), INDEX `field_cvm_cvm_context` (`field_cvm_cvm_context`), INDEX `field_cvm_cvm_view_context` (`field_cvm_cvm_view_mode`, `field_cvm_cvm_context`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Data storage for field 32 (field_cvm_cvm)'; Array ( ) in db_create_table() (line 2717 of /includes/database/database.inc).

EDIT:
I'm not getting this error with my local development installation so it might be a different issue than the OP. Seems to be related to #2120467: Hard to uninstall as the field in question (field_cvm_cvm) is created programmatically in the .module file and not from the .install file.

EDIT 2:
I filed a separate issues for this:
#2159763: PDOException: Specified key was too long; max key length is 1000 bytes: CREATE TABLE {field_data_field_cvm_cvm}.

Frank Ralf’s picture

Issue summary: View changes
Related issues: +#2120467: Hard to uninstall
sherakama’s picture

I have added the change in original post/#6. Thanks everyone for this.

Please review and mark as "RBTC" and I will put out a new stable.

sherakama’s picture

Status: Needs work » Needs review
Frank Ralf’s picture

I think the patch from #6 is not sufficient to solve this issue. There are certain edge cases where your Drupal installation ends up without the field_cvm_cvm field even when the module and its sub module are enabled (the following instructions are for the current dev version with the CVM Field sub module):

  1. Install the parent module together with the sub module and enable them. => The required fields will be created.
  2. Disable and uninstall the parent module, leave the sub module untouched. => All field will be deleted from the database.
  3. Enable the parent module again. => You will get the error from the OP.

The fields only get re-created by disabling and re-installing also the sub module. That's the reason this issue is linked to #2120467: Hard to uninstall.

hth
Frank

webmestre’s picture

Same issue for me :

FieldException : Tentative de créer une instance d'un champ field_cvm_cvm qui n'existe pas ou qui est actuellement inactif. dans field_create_instance() (ligne 476 dans /home/xxxxx/xxxxxxxx/modules/field/field.crud.inc).

Any idea ?

sherakama’s picture

I am getting rid of the CVM field in the 2.x version and changing the global options to allow more entity types than just nodes. These issues will be addressed in that version.

sherakama’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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