Skip to content

add records with createOptionForm from inside MyCustomComponent triggers "Call to a member function isRelation() on null" #429

Description

@KONEY

Hello!

I implemented a custom component to add some functionalities like adding CC emails to user data.

On a working MyCustomComponent I have a relationship multiselect which should be able to add new items.

` public function mount()
{
$this->user=auth()->user();
$this->userClass=get_class($this->user);
$this->form->model($this->user);
$this->form->fill($this->user->only($this->only));
}

public function form(Form $form): Form
{
	return parent::form($form)
		->statePath('data')
		->schema([
			Select::make("emails_ccs")
				->label("E-Mails CC")
				->relationship("emails_ccs", "email")
				->getOptionLabelsUsing(fn(array $values):array=>$this->user->emails_ccs->pluck('email','id')->toArray())
				->multiple()
				->createOptionForm([
					TextInput::make("email")
						->required()
						->email()
					])
			]);
}`

Image

This works correctly but when clicking the "+" button an error is triggered: "Call to a member function isRelation() on null." and I'm not sure what's the problem.

Image

I tried this solution #293 but the add button won't work at all.

Thanks for any help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions