Input

new Input(options) → {Class}

A input component .

Parameters:
NameTypeDescription
optionsobject

The options for the component.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes for the component.

customClassesArray

An array of additional classes for the component.

idstring

Id for the component, auto generated if not passed.

inputPrefixstring

The prefix for the input.

inputSuffixstring

The suffix for the input.

labelstring

For radio or checkboxes, the label text.

labelAttributesstring

Any other arbitrary attributes to add to the label.

labelClassesstring

Space separated string of classes to add to the label.

placeholderstring

Input placeholder text.

renderedstring

Is the component already rendered in the dom, eg by php?

renderOnInitstring

Render the component on init of the class?

spacingstring

Spacing for the component.

targetstring

The target to render to. Any valid css selector string.

targetPositionstring

The insert position for the component relative to the target.

themestring

Theme for the component, primary or cosmos.

typestring

Input type: text, email, tel, url, checkbox or radio.

valuestring

The value for the input.

Since
  • 1.1.16
Returns:

The class instance.

Type: 
Class
Example
import Input from '@gravityforms/components/html/admin/elements/Input';

function Example() {
     const inputInstance = new Input( {
         id: 'example-input',
         renderOnInit: false,
         target: '#example-target',
         targetPosition: 'beforeend',
         theme: 'cosmos',
     } );

     // Some time later we can render it. This is only done if we set renderOnInit to false.
     // If true it will render on initialization.
     inputInstance.init();
}

Methods

(static) init() → {void}

Initialize the component.

Since
  • 1.1.16
Returns:
Type: 
void

(static) inputTemplate(options) → {string}

Generates the markup for a input in the admin.

Parameters:
NameTypeDescription
optionsobject

The options for the component template.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes.

customClassesArray

An array of additional classes for the toggle.

idstring

Id for the input, auto generated if not passed.

inputPrefixstring

The prefix for the input.

inputSuffixstring

The suffix for the input.

labelstring

For radio or checkboxes, the label text.

labelAttributesstring

Any other arbitrary attributes to add to the label.

labelClassesstring

Space separated string of classes to add to the label.

placeholderstring

Input placeholder text.

actionButton
actionButtonIcon
spacingstring | number | Array | object

The spacing for the component, string, number, object or array.

themestring

Theme for the toggle, primary or cosmos.

typestring

Input type: text, email, tel, url, checkbox or radio.

valuestring

The value for the input.

Since
  • 1.1.16
Returns:
Type: 
string
Example
import { inputTemplate } from '@gravityforms/components/html/admin/elements/Input';

function Example() {
     const inputTemplateHTML = inputTemplateTemplate( options );
     document.body.insertAdjacentHTML( 'beforeend', inputTemplateHTML );
}

(static) render() → {void}

Renders the component into the dom.

Since
  • 1.1.16
Returns:
Type: 
void