I would like to create a field for my Entityform same as 'Select list' with ability to change its values after the data is submitted.
Currently when I am trying to change the default values of 'Select list' it gives me the error:
Allowed values list: some values are being removed while currently in use.
or:
There is data for this field in the database. The field settings can no longer be changed.
I believe this behaviour should be different than for Content type, as when using Entityform I don't care for already submitted data (as it's something that suppose to be submitted only once)?
Question
How do I create a Select list widgets on Entity forms where I am able to change its key values once the data has been submitted?
How do I fix or workaround that Drupal limitation, or I should use a different solution/module instead or write my own?
Example scenario
So for example I want to create a Select list widget (e.g. contact_by field) appearing on Entity form which has the following values:
by_phone|By Phone
by_email|By Email
ops_typo|By Post (fixme: correct typo)
by_fax|By Fax (fixme: remove me)
So the critical scenario would be a strong need of changing these values such as typo (correcting ops_typo
) or changes in business requirement how these form works (e.g. I want to remove by_fax
appearing on the submission forms for new forms), however it is currently not possible by using a standard Select list widget, because it has already some existing data associated with that value
Reproducible steps
- Launch Drupal sandbox.
- As admin, add a new entityform type (Admin/Structure/Entityform Types/Add) for auth users: Test
- Add new required field Contact By of List (text) type as Select list widget pasting above values.
- Create two entity forms (Admin/Structure/Entityform Types/Submit Link or at /eform/submit/test), one with By Post, another with By Fax values.
- Now go to Manage fields of that Entityform, in 'edit field' or 'field settings' try removing/changing the last two values (the key part, not label).
Data storage
As per comment concern, the change of value won't corrupt any existing data (despite of the warning), because the value in stored is database in the text format anyway, for example:
INSERT INTO `field_data_field_title` VALUES ('entityform','test_title',0,207,207,'und',0,'Foo');
INSERT INTO `field_revision_field_title` VALUES ('entityform','test_title',0,207,207,'und',0,'Foo');
which has the references to the right entityform
:
INSERT INTO `entityform` VALUES (208, 'test_title', '', 1447192797, 1447192797, X'733A303A22223B', 1, 0, NULL);
So when viewing the entity form (e.g. /entityform/208
) is just showing plain text. I don't need to edit that data, as it's just one-off form submission.
keys
from old submissions will be lost if you change thekey|value
pair to new values. So Drupal is warning that you willcorrupt
data. If you just want a generic select list of only text values perhaps try atextfield
with custom javascript auto-complete from your own store of values.