Let flavor fields show the default value

Now there is no way to define initial value for flavor field.
This patch fix this.

Change-Id: I966370ced17e39fbe8570226c655fb805cc4e879
Closes-Bug: #1650406
This commit is contained in:
zhurong 2016-12-21 17:11:12 +08:00
parent b5487f28da
commit 3ba5bfd86b
2 changed files with 16 additions and 5 deletions

View File

@ -350,11 +350,18 @@ class FlavorChoiceField(ChoiceField):
choices.sort(key=lambda e: e[1])
self.choices = choices
# Search through selected flavors
for flavor_name, flavor_name in self.choices:
if 'medium' in flavor_name:
self.initial = flavor_name
break
if kwargs.get('form'):
kwargs_form_flavor = kwargs["form"].fields.get('flavor')
else:
kwargs_form_flavor = None
if kwargs_form_flavor:
self.initial = kwargs["form"]["flavor"].value()
else:
# Search through selected flavors
for flavor_name, flavor_name in self.choices:
if 'medium' in flavor_name:
self.initial = flavor_name
break
class KeyPairChoiceField(DynamicChoiceField):

View File

@ -0,0 +1,4 @@
---
features:
- |
Flavor field will show the initial value by default.