Work around bug where fields with only names provided are broken on init
This commit is contained in:
parent
b12337292d
commit
e001ed6f1b
1 changed files with 15 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
// License: LGPL-3.0-or-later
|
||||
import {Field, Form} from "mobx-react-form";
|
||||
import {Field, FieldDefinition, Form, initializationDefinition} from "mobx-react-form";
|
||||
import {action, computed, IValueDidChange, observable, runInAction} from 'mobx'
|
||||
import * as _ from 'lodash'
|
||||
import {ValidationErrorsException} from "../../api";
|
||||
|
@ -7,7 +7,20 @@ import validator = require("validator");
|
|||
|
||||
|
||||
export class HoudiniForm extends Form {
|
||||
|
||||
constructor(definition?:initializationDefinition, options?:any){
|
||||
//correct the bug where field initializations with just names don't work
|
||||
if (definition && definition.fields){
|
||||
definition.fields = definition.fields.map((i:FieldDefinition) =>
|
||||
{
|
||||
if (_.entries(i).length == 1)
|
||||
{
|
||||
i.extra = null
|
||||
}
|
||||
return i
|
||||
})
|
||||
}
|
||||
super(definition, options)
|
||||
}
|
||||
|
||||
@observable
|
||||
private $serverError:string
|
||||
|
|
Loading…
Reference in a new issue