2017-07-17 46 views
2

由於某種原因,ReferenceInput在我的Edit窗體上工作正常;但在創建窗體上,它顯示爲禁用且爲空(我對這兩種窗體都使用相同的代碼)。它也不會在chrome開發工具中顯示任何錯誤。我是否需要爲Create窗體創建任何其他內容?謝謝admin-on-rest ReferenceInput適用於編輯但不創建

+0

請分享您的代碼 –

+3

你可能必須設置allowEmpty上referenceInput在創建 –

+0

@kunalpareek啊啊啊這是真的,要麼或設置默認值,我猜。應該在文件中提到。謝謝 :) –

回答

1

這對我有用。注意「allowEmpty」在ReferenceInput

<Create title="My title" {...props}> 
    <SimpleForm> 
     <TextInput label= "field 1" source="f1" validate={[ required, minLength(3), maxLength(20) ]} /> 
     <ReferenceInput label="field 2" source="f2" validate={[ required ]} reference="reference1" allowEmpty> 
      <AutocompleteInput optionText="f3" /> 
     </ReferenceInput> 
    </SimpleForm> 
</Create> 
相關問題