Skip to content

Commit 6d7123a

Browse files
authored
docs(MigrationGuide - Form): outline HTML form handling (#6385)
1 parent 2c5c98f commit 6d7123a

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

docs/MigrationGuide.mdx

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,9 @@ Since the `ObjectPage` isn't compatible with the `DynamicPageTitle` web componen
376376
The `Form` component has been replaced with the `ui5-form` Web Component.
377377
You can use the new `Form` component as a feature complete replacement of the old Form component with the important differences to mention:
378378

379-
1. You can't mix `FormGroup`s and `FormItem`s as children of the Form. Either only use `FormItem`s or only `FormGroup`s with `FormItem`s inside.
380-
2. Additional HTML elements between `Form / FormGroup / FormItem` are not allowed. You can still use custom React components if they render a `FormGroup` or `FormItem` as most outer element (or a fragment).
379+
1. The `ui5-form` web component doesn't implement the events, attributes and properties of an HTML `form` element. So, if you want these features to be available, we recommend wrapping the `Form` component inside a HTML `form` element.
380+
2. You can't mix `FormGroup`s and `FormItem`s as children of the Form. Either only use `FormItem`s or only `FormGroup`s with `FormItem`s inside.
381+
3. Additional HTML elements between `Form / FormGroup / FormItem` are not allowed. You can still use custom React components if they render a `FormGroup` or `FormItem` as most outer element (or a fragment).
381382

382383
```tsx
383384
// v1
@@ -397,6 +398,9 @@ function MyComponent() {
397398
columnsL={3}
398399
columnsXL={4}
399400
as={'form'}
401+
onSubmit={(e) => {
402+
/*handleSubmit*/
403+
}}
400404
>
401405
<FormGroup titleText="My Form Group" as="h5">
402406
<FormItem label={'MyLabel'}>{/* FormItem Content */}</FormItem>
@@ -410,22 +414,29 @@ import { Form, FormGroup, FormItem, Label } from '@ui5/webcomponents-react';
410414

411415
function MyComponent() {
412416
return (
413-
// `backgroundDesign` and `as` have been removed without replacement
414-
<Form
415-
// `titleText` has been renamed to `headerText`
416-
headerText="My Form"
417-
// the `columnsX` props have been merged into the `layout` string
418-
layout="S1 M2 L3 XL4"
419-
// the `labelSpanX` props have been merged into the `labelSpan` string
420-
labelSpan="S1 M2 L3 XL4"
417+
// To implement HTML form features, use the `form` element
418+
<form
419+
onSubmit={(e) => {
420+
/*handleSubmit*/
421+
}}
421422
>
422-
{/* `titleText` has been renamed to `headerText`, `as` has been removed */}
423-
<FormGroup headerText="My Form Group">
424-
{/* the `label` prop has been renamed to a `labelContent` slot.
423+
{/* `backgroundDesign` and `as` have been removed without replacement */}
424+
<Form
425+
// `titleText` has been renamed to `headerText`
426+
headerText="My Form"
427+
// the `columnsX` props have been merged into the `layout` string
428+
layout="S1 M2 L3 XL4"
429+
// the `labelSpanX` props have been merged into the `labelSpan` string
430+
labelSpan="S1 M2 L3 XL4"
431+
>
432+
{/* `titleText` has been renamed to `headerText`, `as` has been removed */}
433+
<FormGroup headerText="My Form Group">
434+
{/* the `label` prop has been renamed to a `labelContent` slot.
425435
It doesn't support strings anymore, it's recommended to use the `Label` component in this slot. */}
426-
<FormItem labelContent={<Label>MyLabel</Label>}>{/* FormItem Content */}</FormItem>
427-
</FormGroup>
428-
</Form>
436+
<FormItem labelContent={<Label>MyLabel</Label>}>{/* FormItem Content */}</FormItem>
437+
</FormGroup>
438+
</Form>
439+
</form>
429440
);
430441
}
431442
```

0 commit comments

Comments
 (0)