Home Reference Source
import BaseInput from 'prg-form/src/BaseInput.jsx'
public class | source

BaseInput

Extends:

Component → BaseInput

Common Input Interface - ABSTRACT

PropTypes

property type type signature description
name string required input name (you can use dots and array indexes)
placeholder string input placeholder (only some inputs)
label string input label
type string input type (only some inputs)
className string input class
controlClass string surrounding paragraph class
defaultValue any is used, when input value is falsey
value any use, when input is operated outside <Form>
onChange function (value, input) => {} fired, when input is changed
onFocus function (input) => {} fired, when input is focused
onBlur function (input) => {} fired, when input is blured
disabled boolean disable input
readOnly boolean only read
required boolean input is required - HTML attribute
maxLength number maximal length (only some inputs)
iconBefore any content shown before input
autoComplete string use "off" to disable autocomplete

Example:

<Input
    name="inputs[0].name"
    label="Text of label"
    className="input-class"
    controlClass="control-container-class"
    disabled
    required
    autofocus
    readOnly
    defaultValue="some value"
/>

Method Summary

Public Methods
public

getValue(): any

Returns input value

public

resetValue(value: *)

Reset and clean the validation errors

public

setError(error: string)

Show error

public

setValue(value: any): any

Set new value to input

Public Methods

public getValue(): any source

Returns input value

Return:

any

public resetValue(value: *) source

Reset and clean the validation errors

Params:

NameTypeAttributeDescription
value *
  • optional

leave empty to reset to default value

public setError(error: string) source

Show error

Params:

NameTypeAttributeDescription
error string
  • optional
  • default: null

error message or nothing to remove error

public setValue(value: any): any source

Set new value to input

Params:

NameTypeAttributeDescription
value any

Return:

any

Example:

// set default value
input.setValue()

// set value
input.setValue('another');