Change the input value in admin-on-rest from another component

I am using admin-on-rest as the admin interface for the application I am creating. There are 3 inputs in the creation form. I need to change the values ​​of these three inputs based on events generated from the antoher component.

export const OfficialPetitionCreate = ( props ) => {

return (
    <div>
        <Create {...props}>
            <TabbedForm>
                <FormTab label="General">
                    ...
                    <TextInput options={{ fullWidth : true }} label="Address" source="address"/>
                    <NumberInput options={{ fullWidth : true }} label="Lat" source="lat"/>
                    <NumberInput options={{ fullWidth : true }} label="Lng" source="lng"/>

                    <GeosuggestInput />

                </FormTab>

            </TabbedForm>
        </Create>
    </div>
);};

So, I want to trigger a change inside the GeosuggestInput component, which will update the recess store for addresses, lat and lng above. A component is a map that handles a click event on a marker. I get the data that I need from this event.

Thank.

======================== Edit. Many thanks to pareek for his reply.

I just needed to use connect to connect to the redux repository.

export default connect ( null , {
    changeLat            : val => change ( 'record-form' , "lat" , val ) ,
    changeLng            : val => change ( 'record-form' , "lng" , val ) ,
    changeAddress        : val => change ( 'record-form' , "address" , val ) ,
    changeMapLocationUrl : val => change ( 'record-form' , "mapLocationUrl" , val ) ,
} ) ( GeosuggestInputComponent );

.props( GeosuggestInputComponent). , val, .

. ,

<MapWithASearchBox changeAddress={this.changeAddress.bind ( this )}
                                   id="map-input"/>

, (, render)

changeAddress ( val ) {
   // # more logic here maybe ?
    this.props.changeAddress ( val );
}

.

+4
1

GeoSuggest FormState, -

https://redux-form.com/7.1.2/docs/api/formvalueselector.md/

, TabbedForm . .

. , , .

AOR

+1

Source: https://habr.com/ru/post/1688463/


All Articles