How to use the react-jsonschema-form/lib/utils.getDefaultFormState function in react-jsonschema-form

To help you get started, we’ve selected a few react-jsonschema-form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Talend / ui / packages / forms / src / deprecated / fields / StringField.js View on Github external
const enumOptions = isSelect(schema) ? optionsList(schema) : undefined;
	const defaultWidget = format || (enumOptions ? 'select' : 'text');
	const { widget = defaultWidget, placeholder = '', ...options } = getUiOptions(uiSchema);
	const Widget = getWidget(schema, widget, widgets);

	const onChangeHandler = value => {
		onChange(value, options);
	};

	return (
		
	);
}
github cloudwan / gohan_webui / src / Form / formComponents / fields / ObjectField.js View on Github external
getStateFromProps(props) {
    const {schema, formData, registry} = props;
    return getDefaultFormState(schema, formData, registry.definitions) || {};
  }
github RxNT / react-jsonschema-form-extras / src / CollapsibleField.js View on Github external
this.setState({ AddElement: undefined });
            this.doAdd(addTo, formData, newVal);
          };
          let AddElement = () => (
             {
                onBlur(formData);
              }}
            />
          );
          this.setState({ AddElement });
        }
      } else {
        let newVal = getDefaultFormState(fieldSchema, {});
        this.doAdd(addTo, formData, newVal);
      }
    });
  };
github cloudwan / gohan_webui / src / Form / formComponents / fields / ArrayField / ArrayField.js View on Github external
onAddClick = event => {
    event.preventDefault();
    const {items} = this.state;
    const {schema, registry} = this.props;
    const {definitions} = registry;
    let itemSchema = schema.items;

    if (isFixedItems(schema) && allowAdditionalItems(schema)) {
      itemSchema = schema.additionalItems;
    }

    const newItems = items.concat([
      getDefaultFormState(itemSchema, undefined, definitions)
    ]);

    this.asyncSetState({
      items: newItems,
      selectedTabId: newItems.length - 1
    });
  };
github dcos / dcos-ui / plugins / services / src / js / containers / framework-configuration / FrameworkConfigurationContainer.tsx View on Github external
onCosmosPackagesStoreServiceDescriptionSuccess() {
    const fullPackage = CosmosPackagesStore.getServiceDetails();
    const packageDetails = new UniversePackage(fullPackage.package);

    const schema = packageDetails.getConfig();
    const frameworkData = getDefaultFormState(
      schema,
      fullPackage.resolvedOptions,
      schema.definitions
    );

    this.setState({ frameworkData, packageDetails, cosmosError: null });
  }
github cloudwan / gohan_webui / src / Form / formComponents / fields / YamlField.js View on Github external
getStateFromProps(props) {
    const {schema, formData, registry} = props;
    return getDefaultFormState(schema, formData, registry.definitions) || {};
  }
github Wiredcraft / jekyllpro-cms / client / src / components / JSONSchemaForm / CustomArrayField.js View on Github external
getStateFromProps(props) {
    const formData = Array.isArray(props.formData) ? props.formData : null;
    const { definitions } = this.props.registry;
    return {
      items: getDefaultFormState(props.schema, formData, definitions) || []
    };
  }
github department-of-veterans-affairs / vets-website / src / js / common / schemaform / fields / ObjectField.jsx View on Github external
getStateFromProps(props) {
    const { schema, formData, registry } = props;
    return getDefaultFormState(schema, formData, registry.definitions) || {};
  }
github dcos / dcos-ui / plugins / services / src / js / pages / EditFrameworkConfiguration.jsx View on Github external
onCosmosPackagesStoreServiceDescriptionSuccess() {
    const fullPackage = CosmosPackagesStore.getServiceDetails();
    const packageDetails = new UniversePackage(fullPackage.package);

    const schema = packageDetails.getConfig();
    const formData = getDefaultFormState(
      schema,
      fullPackage.resolvedOptions,
      schema.definitions
    );

    const defaultConfigWarning = fullPackage.resolvedOptions
      ? null
      : i18nMark(
          "This service was initially deployed to a previous version of DC/OS that did not store service configuration settings. The default package values were used to populate the configuration in this form. Carefully verify the default settings are correct, prior to deploying the new configuration."
        );

    this.setState({
      cosmosErrors: null,
      packageDetails,
      formData,
      defaultConfigWarning