Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding entries to FieldList #850

Open
Lopkop opened this issue Jul 16, 2024 · 0 comments
Open

Adding entries to FieldList #850

Lopkop opened this issue Jul 16, 2024 · 0 comments

Comments

@Lopkop
Copy link

Lopkop commented Jul 16, 2024

Actual Behavior

This is my fields and html code:

class FileForm(FlaskForm):
    filename = StringField('Filename')
    value = TextAreaField('Paste', validators=[DataRequired()])


class PasteForm(FlaskForm):
    paste = FieldList(FormField(FileForm), min_entries=1)
    submit = SubmitField('Create paste')
{% for field in form.paste %}
<p>
    {{ field.filename(placeholder='Filename') }}

</p>
<p>
    {{ field.value(wrap='off') }}
</p>
{% endfor %}
<form>

I found on reddit, that format is <form_variable_name>-<id_number> for creating new entries. So I added it, but I just got new blank form in FieldList.
First question: Why there is no information about this in documentation?
Second question: Why below html just adds blank form to FieldList with blank filename and value ? (see result below)

<input name="paste-1" type="text">
<textarea name="paste-1"></textarea>

This is an output if I am filling all 2 forms:
[{'filename': 'test.py', 'value': "print()", 'csrf_token': None}, {'filename': None, 'value': None, 'csrf_token': None}]
As you can see only first form has values

What I expected to see?

  1. Documentation about this feature
  2. filename and value filled with values

Environment

  • Python version: 3.11.9
  • wtforms version: 3.1.2
@Lopkop Lopkop changed the title adding entries to FieldList Adding entries to FieldList Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant