oTree Forum >

Dynamic number of form_fields

#1 by Hauke

Hi!

I am working on an app that reads in a csv file. Based on the number of rows of that file (which may vary from session to session), I'd like to create form fields.

How would I do that? Or: should I do that at all?

Thanks in advance.

#2 by Chris_oTree

First define N fields on your Player model. (Where N is the max number of form fields you could possibly have.)

Then use get_form_fields to load the CSV file and return the names of the form fields you want to use.

Write a reply

Set forum username