Dynamic generation of Select Widget options based on answer to an earlier form field

In my form.yml.erb I’m executing a shell command to dynamically generate the list of SLURM partitions a user has access to in our cluster and dynamically populating the select widget options for the ‘custom_queue’ form field.

Now based on the slurm partition choosen from the drop down menu I want execute another shell command to generate a list of the SLURM account names and populate the select widget options for the next form field where I’m allowing the user to select the SLURM account.

Would it be possible to dynamically generate the select widget options by running a command on the node using the answer provided on an earlier form field ?

Are these any examples of such forms developed any where ?

Thanks,
Krishna.