From 7b03fa16c50f2250bcc16284016cb05f501ec51a Mon Sep 17 00:00:00 2001 From: haraldox Date: Fri, 19 Jan 2018 16:36:26 +0100 Subject: fix invite screen [object Object] value mobx-react-form expects nested `fields` property in array --- src/components/auth/Invite.js | 22 +++++++++++----------- src/helpers/validation-helpers.js | 2 +- src/lib/Form.js | 5 +++-- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/components/auth/Invite.js b/src/components/auth/Invite.js index c1d815dcd..dface4fe1 100644 --- a/src/components/auth/Invite.js +++ b/src/components/auth/Invite.js @@ -45,17 +45,17 @@ export default class Invite extends Component { form = new Form({ fields: { invite: [...Array(3).fill({ - name: { - label: this.context.intl.formatMessage(messages.nameLabel), - // value: '', - placeholder: this.context.intl.formatMessage(messages.nameLabel), - }, - email: { - label: this.context.intl.formatMessage(messages.emailLabel), - // value: '', - validate: [email], - placeholder: this.context.intl.formatMessage(messages.emailLabel), - }, + fields: { + name: { + label: this.context.intl.formatMessage(messages.nameLabel), + placeholder: this.context.intl.formatMessage(messages.nameLabel), + }, + email: { + label: this.context.intl.formatMessage(messages.emailLabel), + placeholder: this.context.intl.formatMessage(messages.emailLabel), + validators: [email], + } + } })], }, }, this.context.intl); diff --git a/src/helpers/validation-helpers.js b/src/helpers/validation-helpers.js index eeb12cab7..a8a242d54 100644 --- a/src/helpers/validation-helpers.js +++ b/src/helpers/validation-helpers.js @@ -13,7 +13,7 @@ export function email({ field }) { isValid = true; } - return [isValid, `${field.label} is not a valid email address`]; + return [isValid, `${field.label} not valid`]; } export function url({ field }) { diff --git a/src/lib/Form.js b/src/lib/Form.js index a22699b45..9b8321948 100644 --- a/src/lib/Form.js +++ b/src/lib/Form.js @@ -21,8 +21,9 @@ export default class DefaultForm extends Form { options() { return { - validateOnInit: false, - // validateOnBlur: true, + validateOnInit: false, // default: true + // validateOnBlur: true, // default: true + // validateOnChange: true // default: false // // validationDebounceWait: { // // trailing: true, // // }, -- cgit v1.2.3-70-g09d2