1
1
Fork 0

Reorganized form field placeholders

dev
Jan Kužílek 5 years ago
parent fc796c4b68
commit 15505539df

@ -22,15 +22,15 @@ class CSRFForm(Form):
csrf_field_name = 'csrf_token'
class LoginForm(CSRFForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username"))
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password"))
remember_me = BooleanField('Remember me')
submit = SubmitField('Log In')
from yadc.models import User
class ResetPasswordForm(CSRFForm):
email = StringField('E-mail', validators=[DataRequired(), Email()])
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Your email address"))
submit = SubmitField('Reset password')
# def validate_email(form, field):
@ -39,10 +39,10 @@ class ResetPasswordForm(CSRFForm):
# raise ValidationError('This')
class RegisterForm(CSRFForm):
username = StringField('Username', validators=[DataRequired()])
email = StringField('E-mail', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()])
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')])
username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username"))
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email"))
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password"))
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password"))
submit = SubmitField('Register')
def validate_username(form, field):
@ -65,8 +65,8 @@ def validate_file(form, field):
class UploadForm(CSRFForm):
post_img = FileField('Image', validators=[validate_file], render_kw={'required':''})
sauce = StringField('Sauce', validators=[DataRequired()], render_kw={'placeholder':'Source URL','autocomplete':'off'})
tags = StringField('Tags', validators=[DataRequired()], render_kw={'placeholder':'Tags','autocomplete':'off'}) # CUSTOM VALIDATOR (also for Post edits)
sauce = StringField('Sauce', validators=[DataRequired()], render_kw=dict(placeholder='Source URL', autocomplete='off'))
tags = StringField('Tags', validators=[DataRequired()], render_kw=dict(placeholder='Tags', autocomplete='off')) # CUSTOM VALIDATOR (also for Post edits)
rating = RadioField('Rating',
choices=[(e.name, e.name.capitalize()) for e in RATING],
default=RATING.safe.name,
@ -88,14 +88,14 @@ class ChangeUserInfoForm(CSRFForm):
userinfo_submit = SubmitField('Change your info')
class ChangePassForm(CSRFForm):
password_current = PasswordField('Current password', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')])
password_current = PasswordField('Current password', validators=[DataRequired()], render_kw=dict(placeholder="Current password"))
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="New password"))
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password"))
pass_submit = SubmitField('Change password')
class ChangeMailForm(CSRFForm):
email = StringField('E-mail', validators=[DataRequired(), Email()], render_kw=dict(placeholder="E-mail"))
email_again = StringField('Repeat e-mail', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat e-mail"))
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email"))
email_again = StringField('Repeat email', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat email"))
mail_submit = SubmitField('Change email')
class ChangeUserRatingForm(CSRFForm):
@ -106,7 +106,7 @@ class ChangeUserRatingForm(CSRFForm):
rating_submit = SubmitField('Change default rating')
class ChangeTagBlacklistForm(CSRFForm):
tags = StringField('Tags', render_kw={'placeholder':'Tags','autocomplete':'off'})
tags = StringField('Tags', render_kw=dict(placeholder='Tags', autocomplete='off'))
tags_submit = SubmitField('Change blacklisted tags', validators=[DataRequired()])
class DeleteUserDataForm(CSRFForm):
@ -136,8 +136,8 @@ def validate_create_required(form, field):
raise ValidationError('Please fill out this field.')
class UserForm(EditForm):
username = StringField('Username', validators=[validate_create_required])
email = StringField('E-mail', validators=[optional(), Email()])
username = StringField('Username', validators=[validate_create_required], render_kw=dict(placeholder='Username'))
email = StringField('Email', validators=[optional(), Email()], render_kw=dict(placeholder='Email'))
user_status = SelectField('User status',
choices=[(e.name, e.name.capitalize()) for e in USER_STATUS],
validators=[optional()])
@ -146,19 +146,19 @@ class UserForm(EditForm):
validators=[optional()])
class PostForm(EditForm):
tags = StringField('Tags', render_kw={'placeholder':'Tags','autocomplete':'off'})
tags = StringField('Tags', render_kw=dict(placeholder='Tags', autocomplete='off'))
rating = SelectField('Rating',
choices=[(e.name, e.name.capitalize()) for e in RATING],
validators=[optional()])
status = SelectField('Status',
choices=[(e.name, e.name.capitalize()) for e in POST_STATUS],
validators=[optional()])
source = StringField('Source', render_kw={'autocomplete':'off'})
source = StringField('Source', render_kw=dict(placeholder='Source URL', autocomplete='off'))
approve = SubmitField('Approve')
class TagForm(EditForm):
content = StringField('Content', validators=[validate_create_required], render_kw={'autocomplete':'off'})
content = StringField('Content', validators=[validate_create_required], render_kw=dict(autocomplete='off'))
category = SelectField('Category',
choices=[(e.name, e.name.capitalize()) for e in TAG_CATEGORY],
validators=[optional()])
@ -166,7 +166,7 @@ class TagForm(EditForm):
# Creation/editing only through post page
class CommentForm(EditForm):
post_id = HiddenField(validators=[validate_create_required])
content = TextAreaField('Comment', render_kw={'autocomplete':'off'})
content = TextAreaField('Comment', render_kw=dict(autocomplete='off'))
def validate_content(form, field):
if (form.create.data or form.edit.data) and not field.data:

@ -6,9 +6,9 @@
<form action="" method="post">
{{ form.csrf_token }}
{{ form.username(placeholder="Username") }}
{{ form.username() }}
{{ form.password(placeholder="Password") }}
{{ form.password() }}
<ul>
<li>

@ -6,13 +6,13 @@
<form action="" method="post">
{{ form.csrf_token }}
{{ form.username(placeholder="Username") }}
{{ form.username() }}
{{ form.email(placeholder="Email address") }}
{{ form.email() }}
{{ form.password(placeholder="Password") }}
{{ form.password() }}
{{ form.password_again(placeholder="Repeat password") }}
{{ form.password_again() }}
<div>
{{ form.submit() }}

@ -7,7 +7,7 @@
<p>Please insert your email address and we will send you a request for password reset.</p>
{{ form.csrf_token }}
{{ form.email(placeholder="Your email address") }}
{{ form.email() }}
{{ form.submit() }}
</form>

@ -17,11 +17,11 @@
<form action="{{ url_for('user.change_pass') }}" method="post">
{{ pass_form.csrf_token }}
{{ pass_form.password_current(placeholder="Current password") }}
{{ pass_form.password_current() }}
{{ pass_form.password(placeholder="Password") }}
{{ pass_form.password() }}
{{ pass_form.password_again(placeholder="Repeat password") }}
{{ pass_form.password_again() }}
{{ pass_form.pass_submit() }}
</form>

Loading…
Cancel
Save