I've got a form, and number of dynamically adding fields,
class EditBook(Form):
title = TextField('title', validators = [Required()])
authors = FieldList(TextField())
that's how I append them
$('form').append('<input type="text" class="span4" id="authors-' + FieldCount +'" name="authors-' + FieldCount +'" placeholder="author ' + FieldCount +'">');
I want to get data from theese inputs. how can I iterate over them, using python?
(or how can I send collected data with jquery to server? I'm new to js and jquery)
guess my inputs aren't connected with authors Fieldlist.
UPDATE
my inputs aren't connected with EditBook though I append them to it.
form.data will solve rest of the problem, when I attach my inputs to form. (now I just get keyerror, trying to access form.data['authors-1'])
now I try to add just a single authors field to copy it later. but it renders invisible, for unknown reason. in blank space should be input, similar to "author-1"
{{form.authors(class="span4", placeholder="author 1")}}
what should I add to code to render this field correctly?

The WTForms process_formdata method will pull these out of the form submission and store them in the data attribute. Below is what your access code will look like. Your authors list should be stored in an iterable that can be accessed with the authors key.
from collections import namedtuple
from wtforms.validators import Required
from wtforms import Form
from wtforms import TextField
from wtforms import FieldList
from webob.multidict import MultiDict
class EditBook(Form):
title = TextField('title', validators = [Required()])
authors = FieldList(TextField())
Book = namedtuple('Book', ['title', 'authors'])
b1 = Book('Title1', ['author1', 'author2'])
# drop them in a dictionary
data_in={'title':b1.title, 'authors':b1.authors}
# Build form and print
form = EditBook(data=MultiDict(data_in))
# lets get some data
print form.data
print form.data['title']
print form.data['authors']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With