@@ -27,6 +27,8 @@ export interface UseChoicesOptions {
2727 optionText ?: OptionText ;
2828 disableValue ?: string ;
2929 translateChoice ?: boolean ;
30+ createValue ?: string ;
31+ createHintValue ?: string ;
3032}
3133
3234/*
@@ -45,11 +47,18 @@ export const useChoices = ({
4547 optionValue = 'id' ,
4648 disableValue = 'disabled' ,
4749 translateChoice = true ,
50+ createValue = '@@ra-create' ,
51+ createHintValue = '@@ra-create-hint' ,
4852} : UseChoicesOptions ) => {
4953 const translate = useTranslate ( ) ;
5054
5155 const getChoiceText = useCallback (
5256 choice => {
57+ if ( choice ?. id === createValue || choice ?. id === createHintValue ) {
58+ // For the create choice, we always use the name prop as text
59+ return get ( choice , 'name' ) ;
60+ }
61+
5362 if ( isValidElement < { record : any } > ( optionText ) ) {
5463 return (
5564 < RecordContextProvider value = { choice } >
@@ -68,7 +77,7 @@ export const useChoices = ({
6877 ? translate ( String ( choiceName ) , { _ : choiceName } )
6978 : String ( choiceName ) ;
7079 } ,
71- [ optionText , translate , translateChoice ]
80+ [ createHintValue , createValue , optionText , translate , translateChoice ]
7281 ) ;
7382
7483 const getChoiceValue = useCallback (
0 commit comments