admin-on-rest - 如何在 Edit 中提供自定义重定向到 SimpleForm?
问题描述
编辑后,我按照约定在列表上重定向。
但是,我需要在列表 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>
);
解决方案
它没有记录,因此我将创建一个问题以将其添加到文档中,但您可以指定一个路径作为redirect
道具:
<SimpleForm redirect={`/list?myParam=${myValue}`}>
见:https ://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/util/resolveRedirectTo.js
推荐阅读
- oracle - 是否可以为现有域创建新的 RCU 模式?
- push-notification - 您能否在多个服务器(Dev、UAT、LIVE)上刷新 APNS 服务器令牌
- python - 使用richDEM计算数字高程模型中的坡度
- powershell - 将 csv 文件作为新工作表附加到现有的 excel
- java - 春季数据可分页,选择不同的一列
- flutter - 图像未显示在 vs 代码中的 flutter.dart 中
- java - 为什么 `Set.of()` 的实现方式与 `Collections.emptySet()` 不同?
- sql - 如何从日期中查找整个日期列的工作日
- javascript - 侧边栏面板 vscode 扩展
- spring-boot - 如何在 jpa 查询中按日期排序