react-admin
react-admin copied to clipboard
ReferenceInput label/source issue
What you were expecting:
label
in <ReferenceInput >
seems not working properly. I'm using version 4.1.1
What happened instead:
Steps to reproduce:
My code
<Create {...props}>
<SimpleForm>
<TextInput source='username' label='帳號' />
<TextInput source='email' label='電子信箱' validate={validateEmail} />
<ReferenceInput source='managedStoreId' reference='store' label='管理店家'>
<SelectInput optionText='storeName' />
</ReferenceInput>
<PasswordInput source='password' label='密碼' />
</SimpleForm>
</Create>
result
And if I change the source
in <ReferenceInput>
like below
<Create {...props}>
<SimpleForm>
<TextInput source='username' label='帳號' />
<TextInput source='email' label='電子信箱' validate={validateEmail} />
<ReferenceInput source='管理店家' reference='store' label='管理店家'>
<SelectInput optionText='storeName' />
</ReferenceInput>
<PasswordInput source='password' label='密碼' />
</SimpleForm>
</Create>
result
label is correct but '管理店家' is not a correct key.
Other information:
Environment "dependencies": { "ra-data-simple-rest": "^4.1.1", "react": "^18.1.0", "react-admin": "^4.1.1", "react-dom": "^18.1.0", "react-scripts": "5.0.1", },
- Browser: chrome
Would you try?
<ReferenceInput source='managedStoreId' reference='store'>
<SelectInput optionText='storeName' label='管理店家' />
</ReferenceInput>
As ReferenceInput
is an input, it accepts a label but it will be ignored - we will update the doc to make it explicit. The displayed label will be the one given for its child.
Please note that this is not the case when the <ReferenceInput>
is used in filters
. There, it also needs the label in the parent element too.
Good catch! that's also why it's confusing.
Would this be a case for using Labeled? @fzaninotto @septentrion-730n