SelectField in wtforms and added <option> via javascript

Viewed 3774

I'm currently work on some project in pyramid and have problem with wtforms SelectField.

I have a 3 SelectField fields:

  • car_make (e.g., "audi")
  • car_model (e.g., "audi 80")
  • car_version (e.g., "AUDI 80 B4").

The car_make choices I can load in the view. The choices for rest of SelectFields (car_model, car_version) I will load on the client side via AJAX/javascript (I can choose car_model when car_make is selected and so on).

The problem is that when I submit the form, car_model and car_version raise 'Not valid choice' because (in SelectField.pre_validation line 431) self.choices is empty.

How can I get around this problem?

1 Answers
Related