Render Field outside Form?

1 Answer 258 Views
Form General Discussions
John
Top achievements
Rank 1
Veteran
John asked on 03 Aug 2022, 07:04 PM

I would like to render a Field component outside the Form render function, is this possible? I would like to leverage the validator prop/logic that comes with the Field component.


const InputValidationWrapper = (fieldRenderProps) => { const { validationMessage, visited, enabledAutoComplete, ...others } = fieldRenderProps; const inputProps = enabledAutoComplete ? others : { ...others, autoComplete: "off" }; return ( <div className="pingora-val-i"> <Input {...inputProps} /> {visited && validationMessage && <Error>{validationMessage}</Error>} </div> ); };

const nameValidator = (value) => (!value ? 'Full Name is required' : '');

const App = () => {

return ( <div> <Field id={'fullName'} name={'fullName'} label={'Full Name'} component={Input} validator={nameValidator} /> </div> ); };


Thanks

1 Answer, 1 is accepted

Sort by
0
Filip
Telerik team
answered on 05 Aug 2022, 12:06 PM

Hi, John,

Currently rendering the Field outside of the render function is not supported.

Field validation can be achieved inside the passed component, more information can be found in the found article:

https://www.telerik.com/kendo-react-ui/components/form/validation/#toc-field-validation


I hope this helps.

Regards, FilipProgress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
Form General Discussions
Asked by
John
Top achievements
Rank 1
Veteran
Answers by
Filip
Telerik team
Share this question
or