informed icon indicating copy to clipboard operation
informed copied to clipboard

acces form outside

Open CRGavrila opened this issue 7 years ago • 2 comments

Hello, when I acces form from outside for ie formApi.getValues(), I get an empty object even if I write in inputs something. PS: If i put a button inside the form I can get values from te inputs with formApi .getValues(). many thanks!

` import React, { PureComponent } from 'react'; import { Form, Text } from 'informed'; import { CustomInput } from '~customs';

export default class App extends PureComponent { constructor(props) { super(props); this.formApi = null; }

render() {
 return (
   <div>
     <Form id="formID" getApi={formApi => this.formApi = formApi}>
       {
            ({ formState, formApi }) => (
              <>
                <Text field="name" />
                <CustomInput field="custom" label="Custom Input" />
              </>
            )
        }
     </Form>
     <button type="button" onClick={ev => console.log(this.formApi.getValues())} />
   </div>
 );
 }

}

`

CRGavrila avatar Jul 04 '19 09:07 CRGavrila

Can u create a codesandbox for this issue

joepuzzo avatar Jul 04 '19 11:07 joepuzzo

Can u create a codesandbox for this issue

Sandbox works perfectly: https://codesandbox.io/s/funny-villani-0k5hc

Is on my side apperently. I have a LayoutPage and i think here is the problem. <LayoutPage header={

header
} content={
content
} footer={
footer
} onRef={layoutRef => this.pageLayout = layoutRef} />

CRGavrila avatar Jul 04 '19 13:07 CRGavrila