diff --git a/test.py b/test.py new file mode 100644 index 00000000..83a10b7c --- /dev/null +++ b/test.py @@ -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) diff --git a/test2.py b/test2.py new file mode 100644 index 00000000..dcf285c6 --- /dev/null +++ b/test2.py @@ -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) diff --git a/test3.py b/test3.py new file mode 100644 index 00000000..b67efc81 --- /dev/null +++ b/test3.py @@ -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)) diff --git a/test4.py b/test4.py new file mode 100644 index 00000000..ba806057 --- /dev/null +++ b/test4.py @@ -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))