How to set field options from React component?

I’m trying to dynamically set field options using context.current as per contextRef | Feathery Docs

However setFieldOptions doesn’t work and I get error TypeError: t3.updateFieldOptions is not a function. A deprecation notice seems to indicate I can set it via the fields object, but I tried that and it’s not working either.
“setFieldOptions is deprecated. Please use the fields object instead and set the options directly on individual fields.”

In accessing context.current.fields.myfield, it returns my undefined as the e3 object isn’t accessible. Any ideas?

Hi @Michael ,

Can you share a code snippet on how you are trying to do this?

Here you go:

  useEffect(() => {
    if (context.current?.fields?.roles && initialValues?.roles) {
      console.log('Setting roles options:', initialValues.roles);
      context.current.fields.roles.options = initialValues.roles.map(role => ({
        value: role,
        label: role
      }));
    }
  }, [context.current?.fields?.roles, initialValues?.roles]);

  // Remove "roles" from initialValues
  const { roles, ...formInitialValues } = initialValues || {};

  return (
    <div id="feathery-form">
      <Form 
        formId={formId}
        initialValues={formInitialValues}
        onSubmit={onSubmit}
        contextRef={context}
      />
    </div>

context.current.fields.roles is inaccessible (it’s a dropdown), and when I console.log context.current I can see fields and roles.