Getting data iterating over wtform fields
Question: 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?

![](http://i.stack.imgur.com/oGIq6.jpg)


Answer: 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']
    

