[FIX] Show custom fields of invalid type (#18794)

pull/18942/head
gabriellsh 5 years ago committed by Diego Sampaio
parent 0147927b69
commit 48e8e9d9e6
No known key found for this signature in database
GPG Key ID: E060152B30502562
  1. 14
      client/components/CustomFieldsForm.js

@ -46,15 +46,21 @@ const CustomFieldsAssembler = ({ formValues, formHandlers, customFields, ...prop
state: formValues[key],
...value,
};
return value.type === 'text'
? <CustomTextInput {...extraProps} {...props}/>
: <CustomSelect {...extraProps} {...props}/>;
if (value.type === 'select') {
return <CustomSelect {...extraProps} {...props}/>;
}
if (value.type === 'text') {
return <CustomTextInput {...extraProps} {...props}/>;
}
return null;
});
export default function CustomFieldsForm({ customFieldsData, setCustomFieldsData, onLoadFields = () => {}, ...props }) {
const customFieldsJson = useSetting('Accounts_CustomFields');
// TODO: add deps. Left this way so that a possible change in the setting can't crash the page (useForm generates states automatically)
const [customFields] = useState(() => {
try {
return JSON.parse(customFieldsJson || '{}');

Loading…
Cancel
Save