After upgrading to 7.x-3.x-dev (from 7.x-3.0-beta1) I can not modify a context anymore. When I save the context I get:

A context with this name already exists. Please choose another name or delete the existing item before creating a new one.

Comments

joelstein’s picture

Priority: Normal » Major

Me too.

likewhoa’s picture

confirmed

mansspams’s picture

same here

Countzero’s picture

Bug confirmed with latest dev.

adamdicarlo’s picture

Also confirming.

The commit causing this must have come after 7.x-3.0-beta1, because that version saves an existing context fine.

Mark Trapp’s picture

This is caused by the latest commit:

From: Frank Febbraro
Date: Wed, 18 May 2011 22:26:09 +0000 (-0400)
Subject: Issue #1141394 by afoster:Change to ctools export UI form caused the validate to... 
X-Git-Url: http://drupalcode.org/project/context.git/commitdiff_plain/acb0cfd?hp=bafd57a5825ff618c5537dbed3c81fa971233b6c

Issue #1141394 by afoster:Change to ctools export UI form caused the validate to not get attached, fixed
---

diff --git a/context_ui/export_ui/context_export_ui.class.php b/context_ui/export_ui/context_export_ui.class.php
index 0dd0cef..c5a4b1a 100644
--- a/context_ui/export_ui/context_export_ui.class.php
+++ b/context_ui/export_ui/context_export_ui.class.php
@@ -102,11 +102,7 @@ function context_ui_form(&$form, &$form_state) {
   // Core context definition
   $form['info']['#type'] = 'fieldset';
   $form['info']['#tree'] = FALSE;
-
-  // Swap out name validator. Allow dashes.
-  if (isset($form['info']['name']['#element_validate'])) {
-    $form['info']['name']['#element_validate'] = array('context_ui_edit_name_validate');
-  }
+  $form['info']['name']['#element_validate'] = array('context_ui_edit_name_validate');
 
   $form['info']['tag'] = array(
     '#title' => t('Tag'),
@@ -297,7 +293,7 @@ function context_ui_edit_name_validate($element, &$form_state) {
   $plugin = $form_state['plugin'];
   // Check for string identifier sanity
   if (!preg_match('!^[a-z0-9_-]+$!', $element['#value'])) {
-    form_error($element, t('The export id can only consist of lowercase letters, underscores, dashes, and numbers.'));
+    form_error($element, t('The name can only consist of lowercase letters, underscores, dashes, and numbers.'));
     return;
   }
 

Checking out commit bafd57a5825ff618c5537dbed3c81fa971233b6c fixes the problem.

muka’s picture

about line 301, context_export_ui.class.php
switching empty() to isset() permit the context to be saved.

  // Check for name collision
  if (isset($form_state['item']->export_ui_allow_overwrite) && $exists = ctools_export_crud_load($plugin['schema'], $element['#value'])) {

Could this break something else?

neurojavi’s picture

Same problem here...
Fix in #7 works for me.

Thanks muka

logaritmisk’s picture

#7 fix works like a charm, thanks!

febbraro’s picture

Status: Active » Closed (fixed)