Skip to content

Commit

Permalink
Merge pull request #1431 from alibaba/fix-switch
Browse files Browse the repository at this point in the history
Fix switch
  • Loading branch information
lhbxs authored Nov 2, 2023
2 parents bd78178 + 4933b25 commit 7333691
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/form-render/src/render-core/FieldItem/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import getRuleList from '../../models/validates';
const UpperContext: any = createContext(() => {});
const valuePropNameMap = {
checkbox: 'checked',
switch: 'checked'
switch: 'checked',
Checkbox: 'checked',
Switch: 'checked'
};

import {
Expand Down Expand Up @@ -124,7 +126,7 @@ export default (props: any) => {
}

// Render field components
let label = getLabel(schema, displayType, widgets);
let label = getLabel(schema, displayType, widgets, fieldProps.addons);
let noStyle = getValueFromKey('noStyle');

const span = getColSpan(formCtx, upperCtx, schema);
Expand Down
6 changes: 3 additions & 3 deletions packages/form-render/src/render-core/FieldItem/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ export const getPath = (path: any) => {
return path;
};

export const getLabel = (schema: any, displayType: string, widgets: any) => {
export const getLabel = (schema: any, displayType: string, widgets: any, addons: any) => {
const { title, description, descWidget, labelWidget } = schema;

const LabelNode = widgets[labelWidget];

if (LabelNode) {
return <LabelNode schema={schema} />
return <LabelNode schema={schema} addons={addons} />
}

if ((!description && !descWidget)) {
Expand All @@ -113,7 +113,7 @@ export const getLabel = (schema: any, displayType: string, widgets: any) => {
const RenderDesc = () => {
const Widget = widgets[descWidget];
if (Widget) {
return <Widget schema={schema} />;
return <Widget schema={schema} addons={addons} />;
}

if (description) {
Expand Down

1 comment on commit 7333691

@vercel
Copy link

@vercel vercel bot commented on 7333691 Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

x-render – ./

x-render-tw93.vercel.app
x-render-git-master-tw93.vercel.app
xrender.fun
www.xrender.fun

Please sign in to comment.