added changes to reflect the default option for dropdown

This commit is contained in:
Vito Albano
2016-11-14 17:27:07 +00:00
committed by Mario Romano
parent f844b0d65f
commit 9d30db9017
2 changed files with 4 additions and 4 deletions

View File

@@ -163,12 +163,12 @@ describe('FormFieldModel', () => {
id: 'dropdown-2',
type: FormFieldTypes.DROPDOWN,
options: [
{ id: 'opt1', value: 'Option 1' },
{ id: 'opt2', value: 'Option 2' }
{ id: 'opt1', name: 'Option 1' },
{ id: 'opt2', name: 'Option 2' }
]
});
field.value = 'opt2';
field.value = 'Option 2';
expect(form.values['dropdown-2']).toEqual(field.options[1]);
});

View File

@@ -234,7 +234,7 @@ export class FormFieldModel extends FormWidgetModel {
if (this.value === 'empty' || this.value === '') {
this.form.values[this.id] = {};
} else {
let entry: FormFieldOption[] = this.options.filter(opt => opt.id === this.value);
let entry: FormFieldOption[] = this.options.filter(opt => opt.name === this.value);
if (entry.length > 0) {
this.form.values[this.id] = entry[0];
}