Newly created option isn't selected when returning from createOptionForm()

As per the attached screen recording gif, the selected item in the menu doesn't reflect the newly created record when creating a new entry via the createOptionForm() method (as below).

Select::make('project_type_id')
  ->columnSpan(6)
  ->hidden(!$userIsAdmin)
  ->options(ProjectType::all()->pluck('type', 'id')->toArray())
  ->relationship('projectType', 'type')
  ->createOptionForm([
      TextInput::make('type')
          ->required()
          ->maxLength(255),
  ])
  ->editOptionForm([
      TextInput::make('type')
          ->required()
          ->maxLength(255),
  ])
  ->manageOptionActions(function ($action) {
      $action
          ->modalWidth('lg')
          ->modalFooterActionsAlignment('end');
  })
  ->preload()
  ->required()


Expected behaviour
When returning from creating a new entry using the createOptionForm() method, I expect that item to be auto-selected in the corresponding Select menu.
CleanShot_2024-05-14_at_22.22.50.gif
Solution
Try to use ->native(false) on the select 🤔

Is there a reason why you use both options and relationship?
Was this page helpful?