cap-collectif / form

Library of @cap-collectif for implementing forms with our Design System
MIT License
1 stars 0 forks source link

added real address to address field with hidden input #33

Closed MedElfadhelELHACHEMI closed 2 years ago

MedElfadhelELHACHEMI commented 2 years ago

Hello there, This PR is to change the Address Component so we can retrieve the address object sent by the GoogleAPI. We use A hidden FieldInput to store the address object so we can have it in the onSubmit method. I didn't add an example to the storybook since it need the GOOGLE_API_KEY

Example

<FormControl name="city" control={control} isRequired>
    <FormLabel label="City" />
      <FieldInput
          type="address"
      name="city"
      control={control}
      defaultValue=""
      placeholder="Address"
      getAddress={add => {
          setValue('realAddress', add)
      }}
      />
</FormControl>
<FormControl
style={{ display: 'none' }}
name="realAddress"
control={control}
isRequired
>
      <FieldInput
          type="hidden"
      name="realAddress"
      control={control}
      defaultValue=""
      placeholder="Address"
          />
    </FormControl>

Thanks

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
dist/form.cjs.production.min.js 26.66 KB (0%)
dist/form.esm.js 20.65 KB (0%)