awcodes / filament-table-repeater

A modified version of the Filament Forms Repeater to display it as a table.
MIT License
201 stars 43 forks source link

Can't get the value from parent #121

Closed khalidmaquilang closed 4 months ago

khalidmaquilang commented 4 months ago

Filament Version

v3

Plugin Version

v3.0.4

PHP Version

PHP 8.3

Problem description

Forms\Components\Select::make('supplier_id')
    ->relationship('supplier', 'name')
    ->live()
    ->required(),
TableRepeater::make('purchaseOrderItems')
    ->headers([
        Header::make('Product Name'),
        Header::make('Quantity'),
        Header::make('Unit Cost'),
    ])
    ->schema([
        Forms\Components\Select::make('product_id')
            ->options(function (Forms\Get $get) {
                return Product::where('supplier_id', $get('supplier_id'))->pluck('name', 'id');
            })
            ->required(),
    ])
    ->columnSpan('full')

When the value of supplier_id changes it should get all Product that is connected to supplier_id but it seems that $get('supplier_id') returns blank.

Expected behavior

I should get the value of supplier_id

Steps to reproduce

Forms\Components\Select::make('supplier_id')
    ->relationship('supplier', 'name')
    ->live()
    ->required(),
TableRepeater::make('purchaseOrderItems')
    ->headers([
        Header::make('Product Name'),
        Header::make('Quantity'),
        Header::make('Unit Cost'),
    ])
    ->schema([
        Forms\Components\Select::make('product_id')
            ->options(function (Forms\Get $get) {
                return Product::where('supplier_id', $get('supplier_id'))->pluck('name', 'id');
            })
            ->required(),
    ])
    ->columnSpan('full')

create a code similar to this

Reproduction repository

No response

Relevant log output

No response

khalidmaquilang commented 4 months ago

sorry.. didn't read the whole docs for repeater.. i got the value of the parent by using $get('../../supplier_id')