admin-on-rest

Show server-side validation errors after failed form submit

安稳与你 提交于 2019-12-10 13:36:01
问题 How can I show validation messages after failed form submit? API request returns HTTP 400 'application/problem+json' response and contains violations as a list with field path. https://tools.ietf.org/html/rfc7807#section-3 { "type": "https://example.net/validation-error", "title": "Your request parameters didn't validate.", "invalid-params": [ { "name": "age", "reason": "must be a positive integer" }, { "name": "color", "reason": "must be 'green', 'red' or 'blue'" } ] } 回答1: I have the

Wrapper component for admin-on-rest

只谈情不闲聊 提交于 2019-12-10 10:08:48
问题 I would like to create a new component that contains Inputs and Fields from aor and use it in <SimpleForm> and <TabbedForm> as below: const WrapperComp = () => { return ( <div> <TextFieldLabel muiTheme={muiTheme}>Title Example</TextFieldLabel>, <TextInput source="status"/>, <TextField source="status"/> </div> ) } <SimpleForm> <WrapperComp /> </SimpleForm> but I get Uncaught Error: The TextInput component wasn't called within a redux-form <Field>. Did you decorate it and forget to add the

How to refresh a List View in admin on rest

随声附和 提交于 2019-12-07 03:24:13
问题 I am trying to get a list to refresh after a custom action was successfully executed. i used the saga from the admin on rest tutorial function * actionApproveSuccess () { yield put(showNotification('Executed')) yield put(push('/comments')) // does not refresh, because the route does not change // react-redux-router also has no refresh() method, like react-router has... } the other idea i had was to somehow trigger the refresh action of the list component, but i have no idea how to access that

Wrapper component for admin-on-rest

半世苍凉 提交于 2019-12-05 18:49:53
I would like to create a new component that contains Inputs and Fields from aor and use it in <SimpleForm> and <TabbedForm> as below: const WrapperComp = () => { return ( <div> <TextFieldLabel muiTheme={muiTheme}>Title Example</TextFieldLabel>, <TextInput source="status"/>, <TextField source="status"/> </div> ) } <SimpleForm> <WrapperComp /> </SimpleForm> but I get Uncaught Error: The TextInput component wasn't called within a redux-form <Field>. Did you decorate it and forget to add the addField prop to your component? . Any help would be appreciated. Thanks! You need to use Field from redux

How to refresh a List View in admin on rest

我的梦境 提交于 2019-12-05 08:18:21
I am trying to get a list to refresh after a custom action was successfully executed. i used the saga from the admin on rest tutorial function * actionApproveSuccess () { yield put(showNotification('Executed')) yield put(push('/comments')) // does not refresh, because the route does not change // react-redux-router also has no refresh() method, like react-router has... } the other idea i had was to somehow trigger the refresh action of the list component, but i have no idea how to access that or how to hook that up to the ACTION_SUCCESS event. There is no way to refresh a route via react

admin-on-rest, redux-form, and trimming field values

半腔热情 提交于 2019-12-05 01:31:15
问题 This is actually less a question than it is me sharing my technique for trimming field values using this library. I'd read every single posting I could find on the matter on Stack Exchange and elsewhere, and could not find a complete working solution. It took me too much time and some trial and error to figure out. With redux-form you must use the change action creator to reset the field value to the trimmed value. The hard part was finding the right place in the code under the right

How can I add a <CreateButton> (seeding the foreign key) to a ReferenceManyField in admin-on-rest

老子叫甜甜 提交于 2019-12-04 13:42:08
问题 I have an edit form for a Post record, and I'm listing the Reviews associated with that Post in a ReferenceManyField/DataGrid (ie <ReferenceManyField target="post_id" reference="reviews"> ). Each Review has the foreign key post_id in the DB. This is all working fine, I have an edit and delete button for each Review row. I need to add a 'Create Review' button for the Post form, such that the post_id field in the Create Review form is pre-populated with the current id of the Post. I'm not very

admin-on-rest, redux-form, and trimming field values

只谈情不闲聊 提交于 2019-12-04 11:47:28
This is actually less a question than it is me sharing my technique for trimming field values using this library. I'd read every single posting I could find on the matter on Stack Exchange and elsewhere, and could not find a complete working solution. It took me too much time and some trial and error to figure out. With redux-form you must use the change action creator to reset the field value to the trimmed value. The hard part was finding the right place in the code under the right conditions to do the trim and fire the action. I tried the normalize method included with redux-form. No. I

How can I add a <CreateButton> (seeding the foreign key) to a ReferenceManyField in admin-on-rest

≡放荡痞女 提交于 2019-12-03 09:23:53
I have an edit form for a Post record, and I'm listing the Reviews associated with that Post in a ReferenceManyField/DataGrid (ie <ReferenceManyField target="post_id" reference="reviews"> ). Each Review has the foreign key post_id in the DB. This is all working fine, I have an edit and delete button for each Review row. I need to add a 'Create Review' button for the Post form, such that the post_id field in the Create Review form is pre-populated with the current id of the Post. I'm not very expert in React/Redux. As @Gildas has suggested above, you need a custom component for that. 1) A

How to create a ReferenceInput wrapped component?

混江龙づ霸主 提交于 2019-12-02 07:21:14
问题 I'm trying to create a wrap component that includes admin-on-rest ReferenceInput What am I missing? I have seen the answer Error on Creating custom ReferenceInput with separate component but I do not know how to apply it in this case //Works!! export const commentsCreate = (props) => ( <Create title = "Create" {...props} > <SimpleForm> <ReferenceInput label="Posts" source="field" reference="posts" allowEmpty {...props}> <AutocompleteInput optionText="name" {...props}/> </ReferenceInput> <