woocommerce/packages/js/components/src/dynamic-form
Brent MacKinnon 8fc82e9bfd
Fix broken links from issue #46336 (#46381)
* Fixing broken links

* Update docs/payments/payment-gateway-api.md

Co-authored-by: Leif Singer <leif@automattic.com>

* Update docs/contributing/common-issues.md

Co-authored-by: Néstor Soriano <konamiman@konamiman.com>

* Update docs/payments/payment-gateway-api.md

Co-authored-by: Leif Singer <leif@automattic.com>

* Update writing-high-quality-testing-instructions.md

* Add changefile(s) from automation for the following project(s): @woocommerce/components, woocommerce-blocks, woocommerce

* ignore MD029 rule (1/2/3) as the linebreaks that are needed for the code block confuse its numbering

* update the docs manifest

`pnpm utils md-docs create docs woocommerce -o docs/docs-manifest.json`

---------

Co-authored-by: Leif Singer <leif@automattic.com>
Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Leif Singer <git@singer.sh>
2024-04-15 14:30:37 +02:00
..
field-types Moved WCA Packages 2022-03-18 14:25:26 -07:00
stories Moved WCA Packages 2022-03-18 14:25:26 -07:00
README.md Fix broken links from issue #46336 (#46381) 2024-04-15 14:30:37 +02:00
dynamic-form.tsx Add/32 react provider to form component (#34082) 2022-08-04 11:14:16 -03:00
index.js Moved WCA Packages 2022-03-18 14:25:26 -07:00
style.scss Moved WCA Packages 2022-03-18 14:25:26 -07:00
types.ts Moved WCA Packages 2022-03-18 14:25:26 -07:00

README.md

DynamicForm

A component to handle form state and provide input helper props.

Usage

const initialValues = { firstName: '' };

<DynamicForm
	fields={ fields }
	onSubmit={ ( values ) => {
		setSubmitted( values );
	} }
	isBusy={ false }
	onChange={ () => {} }
	validate={ () => ( {} ) }
	submitLabel="Submit"
/>;

Props

Name Type Default Description
fields {} or [] [] An object to describe the structure and types of all fields, matching the structure returned by the Settings API
isBusy Boolean false Boolean indicating busy state of submit button
onSubmit Function noop Function to call when a form is submitted with valid fields
onChange Function noop Function to call when any values on the form are changed
validate Function noop A function that is passed a list of all values and should return an errors object with error response
submitLabel String "Proceed" Label for submit button.

Fields structure

Please reference the WordPress settings API documentation to better understand the structure expected for the fields property. This component accepts the object returned via the settings property when querying a gateway via the API, or simply the array provided by Object.values(settings).

Currently Supported Types

  • Text
  • Password
  • Checkbox
  • Select