Socket
Book a DemoInstallSign in
Socket

formio-utils

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formio-utils

Utility functions for form.io

0.2.4
latest
npmnpm
Version published
Weekly downloads
89
5.95%
Maintainers
4
Weekly downloads
 
Created
Source

formio-utils

Utility functions for form.io

Installing

$ npm install formio-utils

Functions

eachComponent(components, fn, includeAll, path)

Calls fn(component) for each component in components, accounting for nested layout components. (Does not call for layout components themselves, unless includeAll is true).

The current data path of the element. Example: data.user.firstName

var utils = require('formio-utils');

utils.eachComponent(form.components, function(component) {
	// Do something...
})

getComponent(components, key)

Returns the component with the given key or undefined if not found.

var utils = require('formio-utils');

var component = utils.getComponent(form.components, 'myKey');

flattenComponents(components, includeAll)

Returns an key-value object where the keys are the keys for each component in components and each key points to the corresponding component. This includes nested components as well. Pass true for includeAll if you want to include layout components.

var utils = require('formio-utils');

var flattened = utils.flattenComponents(form.components);
console.log(flattened['myNestedComponent']);

isLayoutComponent(component)

Determine if a component is a layout component.

var utils = require('formio-utils');

var layoutComponent = utils.isLayoutComponent(form.components[0]);
console.log(layoutComponent);

getValue(submission, componentKey)

Get the value for a components API key, from the given submission. Recursively searches the submission for the key.

var utils = require('formio-utils');

var value = utils.getValue(submission, 'myComponent'); // The value or undefined.

Testing

$ npm run test

FAQs

Package last updated on 27 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.