public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Forms\Components\Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
// ->reactive()
// ->afterStateUpdated(function($state,callable $set)
// {
// })
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->label('MC')
->inline(false),
])->columns(4),
... public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Forms\Components\Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
// ->reactive()
// ->afterStateUpdated(function($state,callable $set)
// {
// })
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->label('MC')
->inline(false),
])->columns(4),
...
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set,Get $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false);
}
}
}
})
->label('MC')
->inline(false),
])->columns(4),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SAVE
</x-filament::button>
')
))
->extraAttributes(['class' => 'flex justify-center']),
])->compact()
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
} public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set,Get $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false);
}
}
}
})
->label('MC')
->inline(false),
])->columns(4),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SAVE
</x-filament::button>
')
))
->extraAttributes(['class' => 'flex justify-center']),
])->compact()
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
}