By Jboo on
Hi,
I installed a module that seems barely supported. It basically added a field to my content types but I've now found an alternative to using this module and have removed and uninstalled it. The problem is that the field that the module has added to my content types is still there. If I try and delete it I get "This field is locked and cannot be deleted" and it's also a required field so I can't edit or add nodes without having to still use the field.
Is there another way I can get rid of the field?
Thanks for any help.
Comments
_
you need to reinstall the module, delete the field, and then disable and uninstall it.
Hi, thanks for the reply but
Hi, thanks for the reply but the problem is still the same. I tried deleting the field before uninstalling but as that didn't work I tried removing the module with no success. I've now tried reinstalling and deleting the field but still with no success.
Is there a way that I can safely remove the field using phpmyadmin?
Thanks again for any help.
My new EasySnoozing, Nursing and BusinessEgghead websites on D7!
_
That should work-- it always has for me. You have to be careful and use the exact version of the module that was installed. Without knowing what 'that didn't work' means, there's not much i can add.
And yes, you can do anything with phpmyadmin, but i wouldn't say it was 'safe'. There's no way to do it unless you know the exact details of field system and module in question.
Here's a code snippet to lock
Here's a code snippet to lock/unlock a field. It can be run quickly via devel's php block. Use it at your own risk.
~Swarnendu Dutta
Remove it from the database
The same thing happened to me once. Ultimately I managed to remove the deactivated field by editing the database.
I would not recommend the
I would not recommend the above in D8. (At least, backup your db before the attempt!).
Worked for me!
Worked for me!
How to remove a locked field?
Instill devel module Enable the devel module either by drush en or from admin/build/modules. It will generate several blocks and look for the one named ‘Execute PHP’ enable it by setting it to a preferred region . Write the code you want to check on the text area for example and then press execute to see the result.
so here we will use this code
$field_name = 'field_name';
$field = field_read_field($field_name);
$field['locked'] = 0; // 0: unlock; 1: lock.
field_update_field($field);
note: this line $field_name = 'field_name'; you have to add your filed name for example like this $field_name = commerce_price;
if you got any error such as displayed as messages “Notice: Undefined index” or “Notice: Undefined variable” and your logs will grow insanely…
the solution is to add in your settings.php the line
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');