score:-1
normally you don't have an access to a record inside a simpleform.
perhaps, you can define a custom field and wrap a textfield inside it with access to the record so as to perform a conditional check as desired.
ex:
const customtextfield = ({record = {}, source}) => (
{ record.foo ? <textfield source="username" label="username" /> : <whateverfield /> }
);
and then, use the customtextfield in your useredit instead.
score:0
are you looking for aor-dependent-input
?
https://github.com/marmelab/aor-dependent-input
it allows to display an input depending on other inputs values. it's authored and supported by the admin-on-rest core team.
score:8
this is not possible with admin-on-rest
but this is where react comes to the rescue, you can create a component to add this behaviour.
something like:
const withprops = ({children,...props}) => children(props);
and use it like this:
export const useredit = (props) => (
<edit {...props}>
<withprops>{({record,...props})=>
<simpleform record={record} {...props}>
<textfield source="username" label="username" />
</simpleform>}
</withprops>
</edit>
);
Source: stackoverflow.com
Related Query
- Access current record in admin on rest edit
- Is there any way to access the current locale with React-Intl?
- How do I access current value of a formik field without submitting?
- How to access current location in reducer (redux-router)?
- How can i access the current hash location on react router 2?
- How can I access current redux state from useEffect?
- No current User AWS Amplify Authentication Error - need access without login
- How to refresh a List View in admin on rest
- how can i access current location from web-page in react native webview
- Is it possible to access the current route component with React Router
- getServerSideProps access current browser url
- Access props and state of current component in React JS within an event handler
- Custom title with image in admin on rest
- Admin On Rest Framework or React drop zone, Issue in uploading a file to firebase
- Ag grid prevents access to current value of React state variable
- React, useRef not allowing to access current properties, getting Uncaught TypeError: Cannot read properties of undefined (reading 'clientHeight')
- How do I access the current route on a Next.JS custom 404 page?
- How can i get access to the current user inside of react from firebase?
- How to access current route from anywhere in my app?
- Admin on rest - How to display a Datagrid withtout a ReferenceField?
- How to access current store state in redux outside of react?
- React-admin Edit title missing record with typescript
- Is there a way to call useEffect only once and also have access to the current state of component?
- Admin on rest Create form - merge firstName and lastName into a third field
- How to access current Redux state with Reselect?
- admin on rest hide resource component in sidebar
- How to access current element on event in react?
- How to access current state on Redux Toolkit on createAsyncThunk
- React and Axios : Axios Can't Access Java/SpringBoot REST Backend Service Because of CORS Policy
- How to concat or delete letters of the current value in input field (redux edit todo item)
More Query from same tag
- How to disable dropdown when a specific option is selected in React?
- Using component as a button React
- yup validation input dependence
- problem when i npm install react-leaflet-draw react-leaflet --save
- redux toolkit state resets
- CardHeader is not rendering in React
- react newforms, set input value and focus field
- Why react-router Route attr render remount not rerender when component update?
- REACT transform a set into an object with assigned keys
- Function passed to child is being interpreted as a string
- Mobx and React. No support for experimental syntax
- Monitoring multiple server stats in React JS
- Hi, I am looking for retaining a state of sorting/pagination while navigating on pages
- How can i re rendered reactjs component
- Material-UI: Button in CardActionArea
- React + MaterialUi handling actions in IconMenu and ListItem
- Formik FieldArray lost focus when "onChange" triggered
- Static site generator that renders React to HTML directly (no React in output)?
- Axios with React gives 200 (304 in network tab), but gives junk HTML response
- Can we assign prototype to child component?
- ReactJS with Socket.IO, server emits to client, but client doesn't emit to server
- VSCode user snippet doesn't works inside jsx
- Getting the CSS right on a sticky bar in ReactJS
- URL changes but page new page is not rendered Ionic React , IonReactRouter with history
- How to make a variable constant name in React
- React checkbox toggle: behaviour is opposite to that expected
- Can not Login with credentials of any other user than the one created at first place Mongodb and react
- Prevent onClick to fire on disabled span
- How to create a controlled input with empty default in React 15
- Cannot update object value, keeps overwriting by strange id | javaScript Mongodb