Form fails when inside createOptionForm but works when it's on it's own page

I have taken my basic user form with a select for roles. When I recreate this form in the createOptionsForm, the select for roles fails. Has anyone else run into this?
1 Reply
ThatWebGuy
ThatWebGuyOP16mo ago
This is my User form...
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('email')
->email()
->required(),
Forms\Components\Select::make('roles')
->multiple()
->relationship('roles', 'name'),
Forms\Components\TextInput::make('password')
->password()
->required(),
]);
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('email')
->email()
->required(),
Forms\Components\Select::make('roles')
->multiple()
->relationship('roles', 'name'),
Forms\Components\TextInput::make('password')
->password()
->required(),
]);
This is the select for another form.
Select::make('primary_contact')
->label('Primary Contact')
->options(User::all()->pluck('name', 'id'))
->searchable()
->columnSpan(1)
->createOptionForm([
TextInput::make('name')
->required(),
TextInput::make('email')
->email()
->unique()
->required(),
Select::make('roles')
->multiple()
->relationship('roles', 'name'),
TextInput::make('password')
->password()
->required()
]),
Select::make('primary_contact')
->label('Primary Contact')
->options(User::all()->pluck('name', 'id'))
->searchable()
->columnSpan(1)
->createOptionForm([
TextInput::make('name')
->required(),
TextInput::make('email')
->email()
->unique()
->required(),
Select::make('roles')
->multiple()
->relationship('roles', 'name'),
TextInput::make('password')
->password()
->required()
]),
This is the exact error I'm getting. "Call to a member function roles() on null"
Want results from more Discord servers?
Add your server