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>
);

Related Query

More Query from same tag