react-admin
react-admin copied to clipboard
AutocompleteInput createLabel prop does not work.
Either the docs need to be updated or the functionality needs to be added.
We still REALLY need this functionality for our office applications as it is not apparent that you can start typing to create a new item. 🤞
https://github.com/marmelab/react-admin/issues/7822
https://marmelab.com/react-admin/AutocompleteInput.html#create
I agree with you, this prop does not work as described so we should fix either the docs or the code.
In the meantime, maybe this can help? (from the section at the very bottom of the AutocompleteInput docs)
The
Create %{item}option will only be displayed once the user has already set a filter (by typing in some input). If you expect your users to create new items often, you can make this more user-friendly by adding a placeholder text like this:const PostCreate = () => { const categories = [ { name: 'Tech', id: 'tech' }, { name: 'Lifestyle', id: 'lifestyle' }, ]; return ( <Create> <SimpleForm> <TextInput source="title" /> <AutocompleteInput onCreate={(filter) => { const newCategoryName = window.prompt('Enter a new category', filter); const newCategory = { id: categories.length + 1, name: newCategoryName }; categories.push(newCategory); return newCategory; }} source="category" choices={categories} + TextFieldProps={{ + placeholder: 'Start typing to create a new item', + }} /> </SimpleForm> </Create> ); }
Thank you!