Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 786 Bytes

create-field.md

File metadata and controls

39 lines (34 loc) · 786 Bytes

Create Field

русская версия create-field.ru.md

import React from 'react';
import {createField, Form} from '@altiore/form';

export const Field = createField(
  ({
    fieldProps,
    inputProps,
    label /* you can add any extra fields here: */,
  }) => {
    return (
      <div>
        <label htmlFor="input-id">
          {label}
          <input id="input-id" {...inputProps} />
        </label>
        <span>{fieldProps.error}</span>
      </div>
    );
  },
);

How to use Use Field properly in your Form with mandatory attribute name =''. Choose FieldArray for arrays.

const MyForm = () => {
  return (
    <Form>
      <Field name="title" />
    </Form>
  );
};