5

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

  1. Launch Drupal sandbox.
  2. As admin, add a new entityform type (Admin/Structure/Entityform Types/Add) for auth users: Test
  3. Add new required field Contact By of List (text) type as Select list widget pasting above values.
  4. Create two entity forms (Admin/Structure/Entityform Types/Submit Link or at /eform/submit/test), one with By Post, another with By Fax values.
  5. 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.

4
  • What is your example select list that is changing over time!? Can you provide an example. The reason you cannot change the select values is that the keys from old submissions will be lost if you change the key|value pair to new values. So Drupal is warning that you will corrupt data. If you just want a generic select list of only text values perhaps try a textfield with custom javascript auto-complete from your own store of values.
    – tenken
    Commented Nov 10, 2015 at 20:37
  • @tenken I understand the limitation and reason behind this, however I don't think it'll corrupt any data (see my addition to the question) as I'm using it for form submissions. I don't have any specific scenario in mind. For example list of interests or other options which would be changed for future submission forms. Hardcoded list without possibility of changing it isn't a good solution.
    – kenorb
    Commented Nov 10, 2015 at 22:10
  • I would always use rules or a custom module to create a new node with the entityform data so that I had full flexibility. I'm still a bit unsure of what you're trying to achieve however. Commented Nov 12, 2015 at 10:30
  • I'm trying to create a select list with changeable list values, as per main question.
    – kenorb
    Commented Nov 12, 2015 at 12:26

1 Answer 1

6

As for workaround, it is possible to use Taxonomy Term Reference field type as Select list, which would provide me a dynamic list of options (list of terms) which can be changed in the future.

However this is not ideal solution for multiple forms from UX perspective, as I have to create a separate taxonomy vocabulary for each widget (or creating a very long one).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.