Files
bflows-bandi-fe/src/components/FormField/components/TextArea/index.js
Vitalii Kiiko 87684bc76b - added bando preview page;
- added bando form preview;
2024-08-27 17:02:16 +02:00

36 lines
1.2 KiB
JavaScript

import React from 'react';
import { classNames } from 'primereact/utils';
import { Controller } from 'react-hook-form';
import { InputTextarea } from 'primereact/inputtextarea';
const TextArea = ({
fieldName,
label,
control,
rows = 4,
errors,
defaultValue,
config = {},
infoText = null
}) => {
return (
<>
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
{label}{config.required ? '*' : null}
</label>
<Controller
name={fieldName}
control={control}
defaultValue={defaultValue}
rules={config}
render={({ field, fieldState }) => (
<InputTextarea id={field.name}
rows={rows}
{...field}
className={classNames({ 'p-invalid': fieldState.invalid })}/>
)}/>
{infoText ? <small>{infoText}</small> : null}
</>)
}
export default TextArea;