1

I have a Wtforms FieldList made up of FormFields that I want to dynamically append to.

To start out, the FieldList is blank, and it shows up as a <ul> tag in the rendered HTML (the HTML here is rendered using an instrumented version of the render_field macro Wtforms uses in examples):

<div class=" form-group field-contain  ">

   <label for="listings" class=" col-md-2 control-label">Listings</label>

      <div class="col-md-10">

         <ul class="form-control" id="listings"></ul>

      </div>
</div>

I also create a Handlebars template that I use to scrape the input and append it as an <li> to the <ul class="form-control" id="listings"> tag. The data is input correctly, here is the HTML after I've

<ul class="form-control" id="listings">
   <li class='form-control' id='listing'>
      <!-- HTML snipped for brevity -->

   </li>
   <li class='form-control' id='listing'>
     <!-- HTML snipped for brevity -- >

   </li>
</ul>

(Note the class='form-control' id='listing' added to the <li> objects were added manually to try to get Wtforms to pick it up)

However, when I do a print(form.listings) serverside it gives me the following output:

<ul id="listings"></ul>

Does anyone know of any special classes/attributes I need to add to the <li> attributes for Wtforms to pick it up serverside? FWIW, if I do a console.log($(form).serialize()) before the form is submitted, the values in the <li>s are in there.

1
  • If the above is not a duplicate, just edit the question explaining what distinguishes your situation and I'll be happy to vote for re-opening :-) Commented Dec 10, 2014 at 2:58

2 Answers 2

0

You must use elements like inputs/options/select to get the POST from form.

Take a look at: Can we use <li> as a form element in html?

Sign up to request clarification or add additional context in comments.

Comments

0

I suspect the problem is that ID's should be unique. see this post. or, simply think how would the function getElementByID work in this case..? Its unclear. So make ID's unique.

If necessary, you can add non-unique properties (like name?) without affecting functionality.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.