class CreateProducts extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form->schema([
Select::make('tag')
->createOptionForm(function () {
return [
TextInput::make('name')->label('Name')->required(),
];
})->createOptionUsing(function ($data) {
dd($data); // This is never called, instead the form is submitted and the Tag will be created.
})
->preload()
->relationship(name: 'tags', titleAttribute: 'name')
->multiple(),
])
->statePath('data')
->model(Product::class);
}
#[Layout('layouts.app')]
public function render(): View
{
return view('products.create-products');
}
class CreateProducts extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form->schema([
Select::make('tag')
->createOptionForm(function () {
return [
TextInput::make('name')->label('Name')->required(),
];
})->createOptionUsing(function ($data) {
dd($data); // This is never called, instead the form is submitted and the Tag will be created.
})
->preload()
->relationship(name: 'tags', titleAttribute: 'name')
->multiple(),
])
->statePath('data')
->model(Product::class);
}
#[Layout('layouts.app')]
public function render(): View
{
return view('products.create-products');
}