mirror of
https://github.com/Xevion/runnerspace.git
synced 2026-01-31 04:25:55 -06:00
Apply new form validation features to New Post form
- Use TextAreaField instead of StringField on forms.NewPostForm - Fixed incorrect remember_me field and redirect in login - Added placeholder usage to field rendering macro
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
{% macro render_field(field) %}
|
||||
{{ field.label }}
|
||||
{{ field(**kwargs)|safe }}
|
||||
{% macro render_field(field, show_label=True) %}
|
||||
{% if show_label %}
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
{{ field(placeholder=field.description, **kwargs)|safe }}
|
||||
{% if field.errors %}
|
||||
<ul class=errors>
|
||||
{% for error in field.errors %}
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
{% extends 'layouts/index.html' %}
|
||||
{% from 'macros.html' import render_field %}
|
||||
|
||||
{% block content %}
|
||||
{% if current_user.is_authenticated %}
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages or true %}
|
||||
<span class="error-message center-message">
|
||||
{{ messages[0] }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<form method="POST" action="{{ url_for('forms.new_post') }}" class="profile-form">
|
||||
<label>
|
||||
<textarea type="text" name="text" placeholder="Write a post between 15 and 1000 characters. Express yourself."></textarea>
|
||||
</label>
|
||||
<button class="button">Create Post</button>
|
||||
<form method="POST" class="form post-form">
|
||||
{{ render_field(form.text, show_label=False) }}
|
||||
<input type=submit value="Create Post">
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<hr style="margin: 2em 0">
|
||||
|
||||
{% for post, author in posts_and_authors %}
|
||||
<div class="post-box">
|
||||
{{ post.text }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<h3>Edit Profile</h3>
|
||||
<form method="POST" action="{{ url_for('forms.edit_profile_post', username=user.username) }}" class="profile-form">
|
||||
<form method="POST" action="{{ url_for('forms.edit_profile_post', username=user.username) }}" class="form">
|
||||
<label>
|
||||
Name<br>
|
||||
<input type="text" name="name" value="{{ user.name }}">
|
||||
|
||||
Reference in New Issue
Block a user