1.1.5 • Published 1 year ago

inertiajs-react-form v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

inertiajs-react-form

Inertia form component identical to formik but uses inertia useForm in the background

NPM JavaScript Style Guide

Install

npm install --save inertiajs-react-form

Parent dependencies

  • react
  • @inertiajs/react

Usage

import { InertiaForm, LabelField, Form } from 'inertiajs-react-form';

function App() {

  return (
    <div className="App">
      <InertiaForm
      onSubmit={(data) => console.log(data)}
      enableReInitialization={true}
      initialValues={{name: '', last_name: ''}}
      >
        {({data, setData, errors, reset, progress,processing,  handleSubmit})=> (
          <>
          <Form>
            <LabelField label='Name' name='name'/>
            <LabelField label='Last Name' name='last_name' />
          </Form>
          <button onClick={handleSubmit}>Submit</button>
          </>
        )}
      </InertiaForm>
    </div>
  );

}

export default App;

InertiaForm

InertiaForm component sets the context using useForm hook and initial values.

props

namedata typerequireddefaultValues
initialValuesobjecttrueundefined
onSubmitfunctiontrueundefined
enableReInitializationbooleanfalsefalse

Form

renders form and passes the submit function

LabeledDropdown

Renders a labled dropdown

props

namedata typerequireddefaultValues
listarraytrue[]
namestringtrue''
labelstringfalse''
errorClassNamestringfalsetext-danger
labelClassNamestringfalseform-label
selectClassNamestringfalseform-select
onChangefunctionfalseundefined
formateLabelfunctionfalseundefined

Formate label example

<LabeledDropdown
 formateLabel={({ name }) => (
     <>
         {name}
     </>
 )}
 list={companies}
 onChange={(value) => setData({
     ...data,
     company_id: value,
 })}
 label="Company"
 name="company_id"
/>

LabelField

props

namedata typerequireddefaultValues
disabledbooleanfalseundefined
namestringtrue''
labelstringfalse''
typestringfalsetext
placeholderstringfalseundefined
errorClassNamestringfalsetext-danger
labelClassNamestringfalseform-label
fieldClassNamestringfalseform-control
onChangefunctionfalseundefined

LabelTextArea

props

namedata typerequireddefaultValues
rowsintegerfalse4
colsintegerfalse5
namestringtrue''
labelstringfalse''
placeholderstringfalseundefined
errorClassNamestringfalsetext-danger
labelClassNamestringfalseform-label
textareaClassNamestringfalseform-control
onChangefunctionfalseundefined

License

MIT © H5SH

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago