By summit on
Hi,
I have a text-list field which already contain values. I would very much like to remove 3 options from the text-list.
But when I try to remove the options, I got:
Allowed values list: some values are being removed while currently in use.
The field TAB says:
There is data for this field in the database. The field settings can no longer be changed.
These settings apply to the check field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.
But if I really know what I am doing and want to remove 2 items of the list. How would I proceed please?
I can't alter it within the database, because it is a BLOB-field. Is there a module in which you can override regular behaviour and change the options in a field.
thanks a lot in advance for your reply!
Greetings,
Martijn
Comments
=-=
make a view of the content which uses the values
use views bulk operations to update that content to use values you aren't trying to remove
test removal of the obsolete values
quick and easy
thanks for this answer. I use VBO for other things... quick and easy here also.
good stuff.
If you don't care about
If you don't care about invalid values in your database (for example when the values are used in test data only that you want to remove later anyway), then the following "patch" disables the check for actual data.
Remember to reverse the patch when you made your changes.
The patch simply adds a zero when checking for existing data, which will always evaluate to FALSE.
Thank you for this post. :-)
Thank you for this post. :-)
Hey,
Hey,
It is working perfectly fine , i have checked in my project.
thanks
mayuri
Improved solution
You can do this without modifying core by overriding the list_field_update_forbid() hook. The warning above still applies, though... do this only if you're not that concerned about potentially having 'dead' list field values in the database that you'll have to clean up. (In other words, your `field_data_field_mylistfield` and `field_revision_field_mylistfield` tables will have the old, invalid values in the `field_mylistfield_value` column.
Also, since the original does nothing unless the field module is 'list' and it has data, you can just not not do anything in your replacement function...
Thank you
Thank you so much this works. It lets you save the form and also revert the feature that contains the fields but I think it is better to update the database directly using a hook_update_N.
Edit: Updating the fields in the database directly won't work without the patch above. The best solution is to delete old fields and create new ones to replace them.
option_trim
have you tried http://drupal.org/project/option_trim ?
Add values to select list
I would like to add some values to the select list. I've added them in the array under 'Allowed values PHP code' and it is showing in the BLOB file under file under the 'field_config' table, but the options are not showing when I try and 'add content'.
Why is this? How do I add values to the select list?
Added note: check is case-insensitive
This one had me going in circles... it seems that one value-item check is case sensitive, while another is case insensitive.
I wanted to change one option "Bacs" to "BACS".
When I changed the item in the "Allowed values list" from:
Bacs|Bacs to BACS|BACS, it gave the error message:
Allowed values list: some values are being removed while currently in use.So, I added BACS|BACS as an additional option so both were in there. Then I changed every node that had "Bacs" selected to "BACS".
Now, at this point, if the words had been different, it would work to simply delete the old value from the Allowed values list. I know that because I had just done it with a different value in the same field, same list. However, when I removed "Bacs|Bacs" from the Allowed values list, it again gave the error message:
Allowed values list: some values are being removed while currently in use.I verified using database tools that there were no fields nor nodes nor views using the 'Bacs" value. I had to remove or change every "BACS" value in any node to something completely different (e.g., "Paypal"), then it allowed the Save settings on the change to remove "Bacs" from the Allowed values list.
If you're going 'round in circles due to this error message, check case sensitivity. Might need to do a 3-stage change to your values,
To anyone that experiences
To anyone that experiences this issue where you can't change the drop-down list field, I've made a video on how to fix this issue:
https://www.youtube.com/watch?v=17dXSVDTlBM
Usually, I use this script to
Usually, I use this script to update the options of fields, that already contains data in the db:
I ran this script on a
I ran this script on a "select list" field and it choked:
Simply empty 2 DB tables
Just Truncate the field_data and field_revision table for specific field.
option1 use taxonomy
option1 use taxonomy
option2 select field_data_field_name to updated allowed value list
https://www.drupal.org/project/image_captcha_indicator
https://www.drupal.org/project/ext_js