Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask
from flask_wtf import FlaskForm, RecaptchaField
app = Flask(__name__)
app.config['WTF_CSRF_ENABLED'] = False
app.config['RECAPTCHA_PUBLIC_KEY'] = 'test'
app.config['RECAPTCHA_PRIVATE_KEY'] = 'test'

class F(FlaskForm):
r = RecaptchaField()

with app.app_context():
f = F()
try:
print(f.r(class_="form-control"))
except Exception as e:
print("ERROR:", e)
13 changes: 13 additions & 0 deletions test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from flask import Flask
from flask_wtf import FlaskForm, RecaptchaField
app = Flask(__name__)
app.config['WTF_CSRF_ENABLED'] = False
app.config['RECAPTCHA_PUBLIC_KEY'] = 'test'
app.config['RECAPTCHA_PRIVATE_KEY'] = 'test'

class F(FlaskForm):
r = RecaptchaField()

with app.app_context():
f = F()
print("type:", f.r.type)
30 changes: 30 additions & 0 deletions test3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask, render_template_string
from flask_wtf import FlaskForm, RecaptchaField
from wtforms import StringField

app = Flask(__name__)
app.config['WTF_CSRF_ENABLED'] = False
app.config['RECAPTCHA_PUBLIC_KEY'] = 'test'
app.config['RECAPTCHA_PRIVATE_KEY'] = 'test'

class F(FlaskForm):
name = StringField("name")
recaptcha = RecaptchaField()

template = """
{% macro render_input(field) %}
INPUT: {{ field(class_="form-control") }}
{% endmacro %}

{% for field in form %}
{% if field.type == "RecaptchaField" %}
{{ field }}
{% else %}
{{ render_input(field) }}
{% endif %}
{% endfor %}
"""

with app.app_context():
f = F()
print(render_template_string(template, form=f))
26 changes: 26 additions & 0 deletions test4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from flask import Flask, render_template_string
from flask_wtf import FlaskForm, RecaptchaField
from wtforms import StringField

app = Flask(__name__)
app.config['WTF_CSRF_ENABLED'] = False
app.config['RECAPTCHA_PUBLIC_KEY'] = 'test'
app.config['RECAPTCHA_PRIVATE_KEY'] = 'test'

class F(FlaskForm):
name = StringField("name")
recaptcha = RecaptchaField()

template = """
{% macro render_input(field) %}
INPUT: {{ field(class_="form-control") }}
{% endmacro %}

{% for field in form %}
{{ render_input(field) }}
{% endfor %}
"""

with app.app_context():
f = F()
print(render_template_string(template, form=f))