0

Hi so suppose I have a list of forms:

class Create(Form):
    cols = []
    for col in ['colA', 'colB', 'colC']:
        cols.append(TextAreaField(col))

When this gets initialized here:

@app.route('/some/path')
def create():
    form = Create()
    return render_template('index.html', form=form)

I want to make sure all these TextAreaField get converted into <textarea id="col#", name="col#"><textarea>. As right now they stay as <UnboundedField(TextAreaField, ('col#,),{})> objects. Right now they are not getting converted

If this is possible any recommendation would be great. Thanks!

<div class="row">
     {% for col in form.cols %}
    <div class="col-md-2">
        <div class="form-group">
        {{ col(rows="20") }}
        {% for error in col.errors %}
            <span style="color: red;">[{{ error }}]</span>
        {% endfor %}
        </div>
    </div>
    {% endfor %}
</div>

AttributeError: 'UnboundField' object has no attribute '__call__'

It obviously works when I have them all separately:

class Create(Form):
    cols = []
    colA = TextAreaField('colA')
    colB = TextAreaField('colB')
    colC = TextAreaField('colC')

Otherwise I wouldnt be asking the question

ququ
  • 1
  • 1

0 Answers0