Using Validation Hooks to set enums of other fields

I am trying to use the tags input type but have the enum that drives the list of valid values for the tags. My idea is to have another field that is a reference input type that references another content model that has the list of values. When that value is selected I would then want to update the enum for the tags input to use the values from it as the dropdown values. I can see in this documentation Using model validation hooks that’s possible to use validation hooks to set the value of another field but how can i set the enumeration of that field?

This is how i am hoping to do it by setting a change hook on the first field but it doesn’t seem to work

const listValue = options.get('listValues');

if (listValue === 'one') {
  model.data.set('tags', { enum: ['seo', 'email', 'social'] });
} else if (listValue === 'two') {
  model.data.set('tags', { enum: ['crm', 'pipeline', 'lead'] });
} else if (listValue === 'three') {
  model.data.set('tags', { enum: ['foo', 'bar', 'baz'] });
}else {
  model.data.set('tags', { enum: [] }); // or default/fallback tags
}

Hello John,

Thank you for sharing this in our forum.

We are still trying to replicate this in our space.

But from what I understand, instead of using validation hook, you could use change hook.

When creating a field in the model, you should see a button more options and in there, you will see something like the image below:

With the change hook, this should trigger when changes happen.

Let us know if you have any other questions.

Thank you,

HI, yes I have tried a change hook, in fact that is how I tried to do this with the code above and it didn’t work. So I am looking for some sample code that can be used in a change hook to set the enum values for another field to create a dependant dropdown.