Search code examples
flaskextractmsg

How to get value (not key) data from SelectField in WTForms if i have same multiple key?


    deliveryMethod = SelectField('Delivery method/Channel', choices = [(1, 'Accounts opened with adequate CDD measures carried out'),(1,'Delivery channels linked with accounts opened with adequate CDD measures carried out'),(2, 'Product serviced by agents'),(2,'Certificate of Deposit'),(4,'Non face-to-face customers'),(4,'Mobile/Internet banking facilities not linked with accounts'),(4,'Products served with unregistered beneficiaries')])

in hear choices have multiple same key.i want get non key values from this,how can get this non key value ?


Solution

  • Choices is a list of tuples. If you just want the "values", try this:

    values = [x[-1] for x in form.deliveryMethod.choices]