For some reason, the ReferenceInput works fine on my Edit form; but on Create form, it shows as disabled and empty (I use the same code for both form). It also doesn't show any error in chrome dev tools. Do I have to do any additional stuff for the Create form to work? Thanks
Asked
Active
Viewed 266 times
2
-
please share your code – kunal pareek Jul 17 '17 at 08:55
-
3you may have to set allowEmpty on referenceInput in create – kunal pareek Jul 17 '17 at 08:55
-
@kunalpareek ahhh that's true, either that or set default value, I guess. Should have been mentioned in the document. Thanks :) – Anh Pham Jul 17 '17 at 13:29
1 Answers
1
This works for me. Note "allowEmpty" in 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>

Fernando Navarro
- 361
- 3
- 9