Skip to main content

Form Components

Email input

<EmailInput
fieldName="email"
label="Email Address"
placeHolder="Enter Email Address"
register={register}
errors={errors}
isRequired
className={styles.emailbox}
labelstyle={styles.labeltext}
/>

propdescriptionrequireddefault
fieldNamefield name of the form element to be registeredtrueNone
registerThis method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.truenone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside email elementfalseEnter Email
labelLabel to be displayed beside email elementfalseEmail
classNameclass name for the elementtrueNone
isRequireddefines whether the element is required for the form submissionfalsefalse
labelstyleclass name for the labeltrueNone
classNamedarkclass name for the element in dark modefalsenull
labeldarkstyleclass name for the element label in dark modefalsenull

TextInput

<TextInput
className={styles.inputbox}
classNamedark={styles.inputbox1}
labelstyle={styles.formlabel}
label="Name"
fieldName="name"
placeHolder="Enter Name"
register={register}
errors={errors}
isRequired
mandatory
charactersOnly/>
propdescriptionrequireddefault
fieldNamefield name of the form element to be registeredtrueNone
registerThis method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.truenone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside elementfalseEnter Value
labelLabel to be displayed beside elementtruenone
classNameclass name for the elementtrueNone
isRequireddefines whether the element is required for the form submissionfalsefalse
maximLengthmaximum number of characters to be enteredfalse20
maximLengthminimum number of characters to be enteredfalse1
charactersOnlyIf the field is characters onlyfalsefalse
labelstyleclass name for the labeltrueNone
classNamedarkclass name for the element in dark modefalsenull
labeldarkstyleclass name for the element label in dark modefalsenull
readOnlyif the element is read onlyfalsefalse
resetCountFlag to check if character count has to be resetfalsefalse
idid for the element if anyfalsenull

PhoneNumberInput

<PhoneNumberInput
className={styles.inputbox}
classNamedark={styles.inputbox1}
labelstyle={styles.formlabel}
placeHolder="Phone Number"
label="Phone Number"
fieldName="phone"
register={register}
errors={errors}
maxLength={13}
isRequired/>
propdescriptionrequireddefault
fieldNamefield name of the form element to be registeredtrueNone
registerThis method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.truenone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside elementfalsePhone Number
labelLabel to be displayed beside elementfalsePhone Number
classNameclass name for the elementtrueNone
isRequireddefines whether the element is required for the form submissionfalsefalse
maximLengthmaximum number of characters to be enteredfalse20
maximLengthminimum number of characters to be enteredfalse1
labelstyleclass name for the labeltrueNone
classNamedarkclass name for the element in dark modefalsenull
labeldarkstyleclass name for the element label in dark modefalsenull
RegularExpBool flag to enable regular expression checkfalsefalse

PasswordField

<PasswordField
fieldName="Password"
label="Password"
register={register}
errors={errors}
placeHolder="Password"
isRequired
minimLength={6}
className={styles.emailbox}
eyeiconstyle={styles.eyeicon}
labelstyle={styles.labeltext}/>
propdescriptionrequireddefault
fieldNamefield name of the form element to be registeredtrueNone
registerThis method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.truenone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside elementfalsePassword
labelLabel to be displayed beside elementfalsePassword
classNameclass name for the elementtrueNone
isRequireddefines whether the element is required for the form submissionfalsefalse
maximLengthmaximum number of characters to be enteredfalse20
minimLengthminimum number of characters to be enteredfalse1
labelstyleclass name for the labeltrueNone
classNamedarkclass name for the element in dark modefalsenull
labeldarkstyleclass name for the element label in dark modefalsenull
RegularExpBool flag to enable regular expression checkfalsefalse

SelectBox

<SelectBox 
className={styles.inputbox}
classNamedark={styles.inputbox1}
name="status"
label="Status"
labelstyle={styles.formlabel}
control={control}
register={register}
values={status}
errors={errors}
placeholder="Choose Status"
mandatory
isRequired/>
propdescriptionrequireddefault
namefield name of the form element to be registeredtrueNone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside elementfalsePlease Select
labelLabel to be displayed beside elementfalseSelectbox
classNameclass name for the elementtrueNone
isRequireddefines whether the element is required for the form submissionfalsefalse
labelstyleclass name for the labeltrueNone
classNamedarkclass name for the element in dark modefalsenull
labeldarkstyleclass name for the element label in dark modefalsenull
defaultvalueDefault value to be selectedfalse0

MultiSelect

<MultiSelect
className={styles.inputbox}
classNamedark={styles.inputbox1}
labelstyle={styles.formlabel}
name="skills"
label="Skills"
control={control}
values={skill.selectdata}
errors={errors}
placeholder="Choose Skills"
mandatory
isRequired/>

className is the styles of the MultiSelect component we can write in the form and it affects when its in light mode and .In dark mode style we passing in classNamedark For label style we passing style in labelstyle we can give label name by 'label=""' fieldName is unique for a field if multiple components is present in th form it is the name we get in the submition of the form . control={control},register={register},errors={errors} must pass it is for error handling and onchange handling of the components When the input component is required field we need to pass isRequired, and when we need mandatory symbol mandatory field must be pass.placeHolder=""

TextArea


<TextAreaField
fieldName="Text Area"
label="Text Area"
register={register}
errors={errors}
placeHolder="Text Area"
isRequired
/>
propdescriptionrequireddefault
fieldNamefield name of the form element to be registeredtrueNone
registerThis method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.truenone
errorsThis prop includes errors if any, for the form elementtrueNone
placeHolderPlaceholder to be displayed inside elementfalseEnter Value
labelLabel to be displayed beside elementfalseText Area
classNameclass name for the elementtrueNone
minimLengthminimum number of characters to be enteredfalse1
isRequireddefines whether the element is required for the form submissionfalsefalse
labelstyleclass name for the labeltrueNone
labeldarkstyleclass name for the element label in dark modefalsenull

DatePicker


<DatePickerComponent
className={styles.dateinputbox}
classNamedark={styles.dateinputbox1}
control={control}
name="dateOfBirth"
isRequired
errors={errors}
label="Date Of Birth"
/>
propdescriptionrequireddefault
namefield name of the form element to be registeredtrueNone
errorsThis prop includes errors if any, for the form elementtrueNone
labelLabel to be displayed beside elementfalseDate
classNameclass name for the elementtrueNone
maxDatemaximum Date that can be selectedfalseCurrent Date
minDateminimum Date that can be selectedfalseCurrent Date - 10 years
isRequireddefines whether the element is required for the form submissionfalsefalse
labelstyleclass name for the labeltrueNone

Form submission

 const apiData = {
name: data.name,
email: data.email,
phone: data.phone,
designation: data.designation.value,
skills,
status: data.status.value,
role: data.role.value,
};
data.designation = data.designation.value;
data.actionUrl = 'employee';
data.actionMethod = 'post';
data.apiData = apiData;
dispatch(Entry(data)).then((resp) => {
setSubmitting(false);
if (resp.payload.code === 200) {
navigate(-1);
} else if (resp.payload.code === 401 || resp.payload.code === 400) {
setError(resp.payload.message);
} else {
setError('Something went wrong!');
}
});
}

passing action url , action method and body data as apiData array we can perform crud operations using this slice.