Chr*_*lin 1 admin-on-rest react-admin
编辑后,我按照惯例在列表上重定向。
但是,我需要在列表 URL 中提供其他参数。
有没有办法在 SimpleForm/Edit 上“欺骗”以自定义重定向?
这是我的代码的相关部分:
const ProviderUserEditActions = ({ basePath, data }) => {
if (! data) return null
return (
<CardActions style={cardActionStyle}>
<ListButton basePath={basePath+'?'+queryString.stringify({providerId:data.providerId, providerName:data.providerName})} />
<RefreshButton />
</CardActions>
);
}
export const ProviderUserEdit = (props) => (
<Edit actions={<ProviderUserEditActions/>} title={<ProviderUserEditTitle />} {...props}>
{/*redirect=false will cause the loosing of the URL parameters :(
but this is the "least worst", because otherwise it would redirect to
'list' but without URL parameters it will completely crash...
we hope that someday we will be able to provide our own redirect
function
*/}
<SimpleForm redirect={false}>
<TextInput source="name" />
<TextInput source="email" />
<TextInput source="phone" />
<BooleanInput source="activated" />
</SimpleForm>
</Edit>
);
Run Code Online (Sandbox Code Playgroud)
它没有记录,所以我会创建一个问题来将它添加到文档中,但你可以指定一个路径作为redirect道具:
<SimpleForm redirect={`/list?myParam=${myValue}`}>
请参阅:https : //github.com/marmelab/react-admin/blob/master/packages/ra-core/src/util/resolveRedirectTo.js
| 归档时间: |
|
| 查看次数: |
1116 次 |
| 最近记录: |