title: Is there a way to dynamically set the default value of a wtform radiofield from within the html template?
body: <p>I'm trying to dynamically set the value of a radio field within the HTML template but I'm not sure how to set the default selection. I want to do this because the forms I want to use are forms that can be saved and re-edited if need be, so I want the default values to be values set when previously saved/submitted. </p>
  
  <p>the wtform fields</p>
  
  <pre class="lang-py prettyprint-override"><code>field_1 = StringField('field_1')
  radio_1 = RadioField('radio_1', choices=[(1,'Yes'),(2,'No')])
  </code></pre>
  
  <p>what i want to be able to do is something like this:</p>
  
  <p>data is database data</p>
  
  <pre><code>{% if data.field_1 = 'X' %}
      {{ form.radio_1(id="radio_1",class="ff-style-radio",default=1) }}
  {% else %}
      {{ form.radio_1(id="radio_1",class="ff-style-radio",default=2) }} 
  {% endif %}
  </code></pre>
  
  <p>I haven't had any success trying this method, swapping default for value, etc. Is something like this possible? If not how would I separate the wtform radio field choices so I can just manually mark which selection is checked? Or should I just use the base HTML method and do something like this:</p>
  
  <pre><code>&lt;ul class="ff-style-radio" id="radio_1"&gt;
      &lt;li&gt;
          {% if data.field_1 = 'X' %}
              &lt;input id="radio_1-0" name="radio_1" type="radio" value="Yes" checked&gt; 
          {% else %}
              &lt;input id="radio_1-0" name="radio_1" type="radio" value="Yes"&gt; 
          {% endif %}        
          &lt;label for="radio_1-0"&gt;Yes&lt;/label&gt;
     &lt;/li&gt;
      &lt;li&gt;
          {% if data.field_1 = 'X' %}
              &lt;input id="radio_1-1" name="radio_1" type="radio" value="No"&gt; 
          {% else %}
              &lt;input id="radio_1-1" name="radio_1" type="radio" value="No" checked&gt; 
          {% endif %} 
          &lt;label for="radio_1-1"&gt;No&lt;/label&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks for any help</p>