Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@degjs/form-field-appender
Advanced tools
A module for adding and saving an infinite number of form fields.
formFieldAppender is a Javascript module that allows you to add and remove an infinite number of similar form fields to a form.
formFieldAppender is an ES6 module. Consequently, you'll need an ES6 transpiler (Babel is a nice one) as part of your Javascript workflow.
If you're already using NPM for your project, you can install formFieldAppender with the following command:
$ npm install @degjs/form-field-appender
Import formFieldAppender and create a new instance of it.
import formFieldAppender from '@degjs/form-field-appender';
let element = document.querySelector('div');
let instance = formFieldAppender(element);
By default, formFieldAppender will search the supplied element
for an item that matches the itemClass
parameter to use as its blueprint.
However, you can optionally provide either an HTML element or string representation of an HTML element as the item blueprint.
import formFieldAppender from '@degjs/form-field-appender';
let element = document.querySelector('div');
let itemBlueprint = document.createElement('div');
itemBlueprint.classList.add('phone-field__wrapper');
itemBlueprint.insertAdjacentHTML('afterbegin', `
<label for="phone-field">Field</label>
<input class="phone-field" name="phone-field" id="phone-field" type="tel">
`);
let instance = formFieldAppender(element, {
blueprint: itemBlueprint
});
import formFieldAppender from '@degjs/form-field-appender';
let element = document.querySelector('div');
let itemBlueprint = `
<div class="phone-field__wrapper">
<label for="phone-field">Field</label>
<input class="phone-field" name="phone-field" id="phone-field" type="tel">
</div>
`;
let instance = formFieldAppender(element, {
blueprint: itemBlueprint
});
Type: HTMLElement
or string
An HTML element or string representation of an HTML element that will be used as the blueprint for the repeating field.
Default: null
Type: string
The class applied to each appended item.
Default: js-ffa-item
Type: string
The selector for each item's add trigger.
Default: .js-ffa-add-trigger
Type: string
The selector for each item's remove trigger.
Default: .js-ffa-remove-trigger
Type: string
The attribute that contains the pattern that will be used to create each appended item's ID. A token of [[itemIndex]]
in the pattern will be dynamically replaced by the item's current index, a token of [[itemElIndex]]
will be replaced by the index of the element within the item, and a token of [[index]]
will be replaced by a hyphenated combination of item and element index (i.e., ffa-id-3-2
for the third element inside the fourth item).
Default: data-ffa-id-pattern
Type: string
The attribute that contains the pattern that will be used to create each appended item's name
attribute. See idPatternAttr
description for available token values.
Default: data-ffa-name-pattern
Type: string
The attribute that contains the pattern that will be used to create each appended item's for
attribute. See idPatternAttr
description for available token values.
Default: data-ffa-for-pattern
Type: string
The class applied to an item when it's hidden/disabled. This class can be used to visibly hide disabled items with CSS.
Default: is-disabled
Type: number
The first index value applied to added items.
Default: 1
Type: boolean
Determines whether the first item can be removed.
Default: true
Type: boolean
Determines whether a "remove" trigger is added to all items, or only the last item.
Default: false
Type: function
or null
An optional callback that's fired whenever an item is added.
Default: null
Type: function
or null
An optional callback that's fired whenever an item is removed.
Default: null
Type: boolean
Determines whether the fields in added items contain the values of the original item/template.
Default: true
Parameters: none
Destroys the formFieldAppender instance.
Parameters: none
Returns an array of the items currently added to the formFieldAppender instance.
formFieldAppender depends on the following browser APIs:
To support legacy browsers, you'll need to include polyfills for the above APIs.
FAQs
A module for adding and saving an infinite number of form fields.
We found that @degjs/form-field-appender demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.