Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.1
-
Fix Version/s: 1.1
-
Component/s: None
-
Labels:None
Description
1. Go to Administer CiviCRM | Custom Data | New Custom Data Group
2. Create a group
3. View and Edit Custom Fields | add one
4. Create a field with Field Label: test?
5. New Custom Field
6. Create a field with Field Label: test.
unrecoverable error
Sorry. A non-recoverable error has occurred.
Database Error Code: Duplicate entry 'test_-4' for key 3, 1062
Return to CiviCRM menu.
error
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -5
[message] => DB Error: already exists
[mode] => 16
[debug_info] => INSERT INTO civicrm_custom_field (custom_group_id , name , label , data_type , html_type , is_required , is_searchable , weight , help_post , is_active ) VALUES ( 4 , 'test_' , 'test.' , 'String' , 'Text' , 0 , 0 , 1 , '' , 1 ) [nativecode=1062 ** Duplicate entry 'test_-4' for key 3]
[type] => DB_Error
[user_info] => INSERT INTO civicrm_custom_field (custom_group_id , name , label , data_type , html_type , is_required , is_searchable , weight , help_post , is_active ) VALUES ( 4 , 'test_' , 'test.' , 'String' , 'Text' , 0 , 0 , 1 , '' , 1 ) [nativecode=1062 ** Duplicate entry 'test_-4' for key 3]
[to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_custom_field (custom_group_id , name , label , data_type , html_type , is_required , is_searchable , weight , help_post , is_active ) VALUES ( 4 , 'test_' , 'test.' , 'String' , 'Text' , 0 , 0 , 1 , '' , 1 ) [nativecode=1062 ** Duplicate entry 'test_-4' for key 3]"]
)
I guess it happens because QuickForm turns both ?test?? and ?test.? into ?test_? and then has duplicate ids.
When resolving this, it might be good to take a look at CRM-297 (i.e., how does exactly QuickForm creates the field ids and whether we can?t easily lax the Field Label validation to allow non-Latin character names), but this is a bonus sub-task.