Flask-WTF: How to define costum variables in Flask FormField

I am trying to setup a dynamic form in Flask where the form has a dynamically populated FieldList of FormFields. While most of it works, I keep running into issues with the variables of each FormField. I need each FormField to have a label which is the name of the FormField (and is rendered on page) and a costum ID which is used in a show/hide script which uses a dynamically filled SelectField to select a sub-form to show and hide. However, I cannot get the variables to retain their state after the form is submitted, which also prevents me from correctly processing the returned data.

These are my form classes:

class ColumnForm(Form):
    text = Label('', '')
    condition = SelectField('Condition', choices=[('eq', 'Equal to'), ('contains', 'Contains')], validators=[Optional()])
    value = StringField(validators=[Optional()])

class CategoryForm(Form):
    catName = ''
    Columns = FieldList(FormField(ColumnForm))
    def add_field(self, name):
        # I have tried several ways of adding the formFields to the FieldList, this is the only way I get the variables to be renamed, but I do not have a way to get the submitted data back
        if not self.checkIfformInFieldList(name):
            self.Columns.append_entry()#{'text' : name})
            self.Columns[-1].form.text = Label(len(self.Columns)-1, name)
            self.Columns[-1].name = name
            self.Columns[-1].id = name
            self.Columns[-1].form.condition.id = f'{name}-condition'
            self.Columns[-1].form.condition.name = f'{name}-condition'
            self.Columns[-1].form.value.name = name+'-value'
            self.Columns[-1].form.value.id = name+'-value'
            self.Columns[-1].form.value.validators = [Optional()] 
    def checkIfformInFieldList(self, name)->bool:
        for column in self.Columns:
            if column.name == name:
                return True
        return False

class baseForm(FlaskForm):
    table_select = SelectField('Select Table', choices=['Select Table'],validators=[Optional()])
    submit = SubmitField('Filter')
    tables = FieldList(FormField(CategoryForm))
    def add_category(self, catName:str, columnNames:list):
        self.tables.append_entry()
        self.tables[-1].name = catName
        self.tables[-1].id = catName
        for columnName in columnNames:
            self.tables[-1].add_field(columnName)

Here is (a simplified version of) my form initialization:

@app.route('/', methods=['GET', 'POST']))
def index():
    form = baseForm(request.form)
    databaseStructure = get_database_structure(db_dict)
    for table in databaseStructure:
        form.table_select.choices.append(table)
    if not form.tables.entries:
        for table, columns in databaseStructure.items():
            form.add_category(table, columns)
    if request.method == 'POST' and form.validate():
        print(form.data)
    return render_template('index.html', form = form)

Here is (a simplified version) of my html template:


<form method="post">
    {{ form.hidden_tag() }}
    <p>
        {{ form.table_select.label }}<br>
        {{ form.table_select }}
    </p>
    {% for category in form.tables %}
    <div id = "{{ category.name }}">
        {% for column in category.Columns %}
        <p>
            {{ column.form.text }}
            {{ column.form.condition }}
            {{ column.form.value }}
        </p>{% endfor %}
</div>
{% endfor %}
    <p>{{ form.submit() }}</p>
</form>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const tableSelect = document.querySelector('#table_select');
        const columnSelect = document.querySelector('#column_select');
        tableSelect.addEventListener('change', function () {
            localStorage.setItem('selectedTable', tableSelect.value)
        });
    });
    window.onload = showFormFunction()
    document.getElementById("table_select").onchange = function() {showFormFunction()};
    function showFormFunction() {
        let table_select_value = document.getElementById("table_select").value;
        {% for tableName in form.tables %}{% if loop.index0 == 0 %}
        if (table_select_value == "{{ tableName.id }}"){ {% else %} else if (table_select_value == "{{ tableName.id }}"){ {% endif %}
            document.getElementById("{{ tableName.id }}").style.display = "inline"; {% for tableNamex in form.tables %} {% if tableName.id != tableNamex.id %}
            document.getElementById("{{ tableNamex.id }}").style.display = "none"; {% endif %} {% endfor %}
        }{% endfor %} else { {% for tableName in form.tables %}
            document.getElementById("{{ tableName.id }}").style.display = "none";{% endfor %}
        }
        
    };
</script>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật