title: Dynamically change WTForms field type between SelectField and HiddenField
body: <p>I have a WTForms field (value_currency) that I want to sometimes be a SelectField and sometimes a HiddenField. I use the same view and template for a page that both creates new items and edits existing items. If I load the page to create a new item, I want this field to be a SelectField, and if I load the page to edit an existing item, I want this field to be a HiddenField because it's a non-editable field.</p>
  
  <p>Here is what I have so far:</p>
  
  <p>FORM</p>
  
  <pre><code>class PromoForm(Form):
      value = StringField('value')
      currencies = Currency.query.order_by(Currency.id).all()
      currency_choices = []
      for currency in currencies:
          currency_choice = (currency.id, currency.name)
          currency_choices.append(currency_choice)
      value_currency = SelectField('value_currency', choices=currency_choices)
  </code></pre>
  
  <p>VIEW</p>
  
  <pre><code>@app.route('/promo/&lt;id&gt;', methods=['GET', 'POST'])
  @login_required
  def promo(id):
      form = PromoForm()
      # Existing promo will pass in its id
      # id = 0 if a new promo is to be created
      if id != str(0):
          # Load existing promo
          promo = Promo.query.get(id)
          # display value in decimal format
          form.value.default = "{0}.{1:0&gt;2}".format(
              promo.value_cents//100, promo.value_cents%100)
          form.process()
          return render_template('promo.html', promo=promo, form=form)
      else:
          # New promo
          audit_log('GET', client, session=session)
          return render_template('promo.html', form=form)
  </code></pre>
  
  <p>TEMPLATE</p>
  
  <pre><code>{% extends "base.html" %}
  {% block content %}
      {% if promo is defined %}
          &lt;form action="{{ url_for('.promo', id=promo.id) }}" method="post"&gt;
      {% else %}
          &lt;form action="{{ url_for('.promo', id=0) }}" method="post"&gt;
      {% endif %}
      {{ form.hidden_tag() }}
      &lt;div&gt;
          &lt;label for="value"&gt;Promo Value&lt;/label&gt;
          {% if promo is defined %}
              {{ form.value() }}
          {% else %}
              {{ form.value() }}
          {% endif %}
          {% for error in form.value.errors %}
              &lt;span class="error"&gt;[{{ error }}]&lt;/span&gt;
          {% endfor %}
          {% if promo is defined %}
              # ----&gt; Promo.value_currency should be a hidden field here (Doesn't work)
              {{ promo.value_currency }}
          {% else %}
              # ----&gt; Promo.value_currency is a select field here (Currently works)
              {{ form.value_currency() }}
          {% endif %}
      &lt;/div&gt;
      &lt;div class="submit_btn"&gt;
          {% if promo is defined %}
              &lt;input type="submit" value="Update Promo"&gt;
          {% else %}
              &lt;input type="submit" value="Create Promo"&gt;
          {% endif %}
      &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>I know I can just simply hardcode the hidden input element and drop in the value with Jinja, but I prefer to do it with WTForms and not do any form element hard coding. Is that possible?</p>