Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:57:29+00:00 2026-06-09T22:57:29+00:00

I am using the render_field macro presented on the Flask-WFT documentation page to render

  • 0

I am using the render_field macro presented on the Flask-WFT documentation page to render fields in long forms across different templates.

A field is defined like this

year_built = IntegerField(label='Year Built', 
             description='Year built, not the year of a major renovation.',
             validators=[validators.NumberRange(
                                    min=1700,  
                                    max=2012, 
                                    message="Between %(min)s and %(max)s")])

The macro looks like this…

{% macro render_field(field) %}
  <dt>{{ field.label }}
  <dd>{{ field(**kwargs)|safe }}
  {% if field.errors %}
    <ul class=errors>
    {% for error in field.errors %}
      <li>{{ error }}</li>
    {% endfor %}
    </ul>
  {% endif %}
  </dd>
{% endmacro %}

In the forms themselves the individual fields are placed using…

{{ render_field(form.year_built, class="input text")}}

What I cannot figure out is a way to use the description in the field object within the part of the macro that creates the HTML field field(**kwargs). I know that I can pass keywords to the render_field function but I am dealing with forms with more than 100 fields and setting the description in the forms.py and then setting it again as a title keyword in the template.html seems like unnecessary repletion. I would really like to use the macro to display a description as a title if it’s there or just display the field without a title if its not.

Is there a way to add new entries to kwargs before the field() function runs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:57:30+00:00Added an answer on June 9, 2026 at 10:57 pm

    So it was much easier than I thought…

    {% macro render_field(field) %}
      <dt>{{ field.label }}
      <dd>{{ field(title=field.description, **kwargs)|safe }}
      {% if field.errors %}
        <ul class=errors>
        {% for error in field.errors %}
          <li>{{ error }}</li>
        {% endfor %}
        </ul>
      {% endif %}
      </dd>
    {% endmacro %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using below code to check some form fields and render datatable table on
I'm currently using NVelocity to render some email templates. I'm curious how I can
I am using a WebBrowser object to render text which is presented in a
I'm using Chameleon in Python to render my templates. Let's say I want to
I am using the Forms library for Node.js ( Forms ), which will render
I have a ruby hash that I'd like to render using RABL . The
I embed text in textfield, but sometimes it does not render using htmltext. if
I am using concrete to render my site, it uses the following error system;
I'm using Java3D to render a three-dimensional scene. I would like to overlay a
I am using formtastic to render a form for a object of a model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.