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
This is my User form...
This is the select for another form.
This is the exact error I'm getting. "Call to a member function roles() on null"
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(),
]);
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()
]),