title: SelectField option to dynamically populate default value in TextAreaField using WTForms
body: <p>I have a SelectField that is populated from a database table. I load the choices into the form as follows:</p>
  
  <pre><code>@statuses.route('/new', methods=['GET', 'POST'])
  @login_required
  def new_status():
      form = StatusForm()
      form.status_cd.choices = [(a.id, a.status_cd) for a in \
                                 Status_Code.query.order_by('status_cd')]
      if form.validate_on_submit():
          status = Status(author=current_user)
          form.to_model(status)
          db.session.add(status)
          db.session.commit()
          flash('The status was added successfully.')
          return redirect(url_for('.index'))
      return render_template('statuses/new_status.html', form=form)  
  </code></pre>
  
  <p>The model referenced in the query is as follows:</p>
  
  <pre><code>class Status_Code(db.Model):
      __tablename__ = 'status_cd'
      id = db.Column(db.Integer, primary_key=True)
      status_cd = db.Column(db.String(16), nullable=False)
      status_detail = db.Column(db.Text)
      is_option_active = db.Boolean()
      date_created = db.Column(db.DateTime, default=db.func.now())
  </code></pre>
  
  <p>And the form class is as follows:</p>
  
  <pre><code>class StatusForm(Form):
      datetime = DateTimeField('Date / Time')
      name = StringField('Name', validators=[Required()])
      status_cd = SelectField('Status Code', coerce=int)
      status_detail = TextAreaField('Status Detail', default="Default text",\
                                  validators=[Required()])
      submit = SubmitField('Submit')
  </code></pre>
  
  <p><strong>The Question</strong></p>
  
  <p>Depending on the option selected in the SelectField, I want it to dynamically set the status_detail TextAreaField's default text. The value from the SelectField should query the database and return the status_detail, which should be the default text. </p>
  
  <p>For example, if I have:</p>
  
  <pre><code>id   status_cd     status_detail
  1    Apple         The apples are red.
  2    Banana        The bananas are yellow. 
  </code></pre>
  
  <p>If the user selects the "Apple" option, the default text should be "The apples are red."</p>
  
  <p>Any assistance would be greatly appreciated! I am building my first Flask app so I'm new to this.</p>