Hi I'm really quite stumped here. I've been trying to get this working for a while, and have just about pulled most of my hair out!..
I have a CCK list(text) select field where the options are populated using ajax based on the value of another field. The problem is, I have not set any 'allowed values' for the select field as they are populated programmatically during form completion. This causes the following problems:
- Can only select 1 value, even though list element is set to 'unlimited'
- Saving form gives illegal choice error
- Editing form will not set default values
I understand why most of this is happening, but not how to work around it in a clean way. I have tried updating the fields allowed values during the ajax call, but I then get "A list field ___ with existing data cannot have its keys changed."
Thanks
Ok I managed to get this working.. What I have achieved is to dynamically update the select list values of an existing CCK field based on the value of another field which contains an ajax callback to re-render the CCK field with the updated values.
Now this would have been a piece of cake if using the form API to create the form/elements from scratch, but sometimes that is not an option when working with entities and existing fields.
In short I did the following: