0

In laravel 10 / filamentphp 3 app I have 3 related country/state/region fields where, when user selects country, then all states are filled correctly and had problems with filling all regions, but after I returned to this issue after some period(1-2 weeks I suppose) I got errors in js console and these features do not work at all .I use code

   ```
                 ->schema([
                        Select::make('country')->label('Country')
                            ->prefixIcon(getLocationIcon())
                            ->preload()
                            ->live(onBlur: true)
                            ->options(ProfileHelper::getCountrySelectionItems(false))
                            ->default(ProfileHelper::getDefaultCountry())
                            ->helperText('Select one countries which are used in the app '),

                        /* BY SELECTING state OF country above list of regions in select below is autofilled */
                        Select::make('state_id')->label('State 987')  // THIS SELECTION IS FILLED CORRECTLY
                            ->options(function (callable $get) {
                                if (empty($get('country'))) {    // THAT IS VALID COUNTRY
                                    return [];
                                }
                                return Geo::getByCountry($get('country'))->getByLevel('ADM1') ->orderBy('name')->pluck('name', 'id');
                            })
                            ->helperText('Select state of the country selected above'),

                        Select::make('region')->label('region')
                            ->options(function (callable $get) {
                                \Log::info(varDump($get('state_id'), ' -145 $get(state_id)::')); // BUT THIS VALUE IS ALWAYS NULL

                                if (empty($get('state_id'))) {
                                    return [];
                                }

                                // SO THE SELEXCTION BELOW IS NOT AUTOFILLED!
                                return Geo::getByCountry($get('country'))->getParentId($get('state_id'))->getByLevel('ADM2')->orderBy('name')->get();
                            })
                            ->helperText('Select region of the state selected above'),

                        TextInput::make('town')
                            ->maxLength(100),
                        TextInput::make('postal_code')
                            ->maxLength(6),
                    ])
```

What I see in browsers console(Version 126.0.6478.61 (Official Build) (64-bit) under kubuntu 22.04) :

enter image description here

enter image description here

enter image description here

enter image description here

I refreshed all packages in composer.json:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^8.2",
        "akaunting/laravel-money": "^5.2.0",
        "awcodes/filament-table-repeater": "^3.0.4",
        "barryvdh/laravel-dompdf": "^2.2.0",
        "bensampo/laravel-enum": "^6.11.0",
        "bezhansalleh/filament-exceptions": "^2.1.1",
        "botman/botman": "^2.8.3",
        "botman/driver-web": "^1.5.3",
        "codewithdennis/filament-select-tree": "^3.1.41",
        "filament/filament": "^3.2-stable",
        "filament/spatie-laravel-media-library-plugin": "^3.2.92",
        "filament/widgets": "^3.2-stable",
        "guzzlehttp/guzzle": "^7.8.1",
        "hasnayeen/themes": "^3.0.23",
        "igaster/laravel_cities": "^1.3.12",
        "jeffgreco13/filament-breezy": "v2.2.1.1",
        "joaopaulolndev/filament-edit-profile": "^1.0.20",
        "joshembling/image-optimizer": "^1.4.1",
        "lara-zeus/popover": "^1.1.5",
        "laravel-notification-channels/telegram": "^4.0.0",
        "laravel/framework": "^10.48.14",
        "laravel/pennant": "^1.8.2",
        "laravel/sanctum": "^3.3.3",
        "laravel/slack-notification-channel": "^2.5",
        "laravel/telescope": "^4.17.6",
        "laravel/tinker": "^2.9.0",
        "leandrocfe/filament-apex-charts": "^3.1.3",
        "livewire/livewire": "^3.5.1",
        "maatwebsite/excel": "^3.1.55",
        "mews/purifier": "^3.4.2",
        "omar-haris/filament-timezone-field": "^1.0.3",
        "orangehill/iseed": "^3.0.4",
        "petercoles/multilingual-country-list": "^1.2.12",
        "phpoffice/phpword": "^1.2",
        "predis/predis": "^2.2.2",
        "pxlrbt/filament-environment-indicator": "^2.0.1",
        "saade/filament-adjacency-list": "^3.2.1",
        "saade/filament-fullcalendar": "^3.2.2",
        "spatie/emoji": "^4.1.1",
        "spatie/geocoder": "^3.16",
        "spatie/laravel-activitylog": "^4.8",
        "spatie/laravel-login-link": "^1.2",
        "spatie/laravel-medialibrary": "^10.15.0",
        "spatie/laravel-permission": "^5.11.1",
        "spatie/laravel-translatable": "^6.7.1",
        "staudenmeir/laravel-adjacency-list": "^1.20.1",
        "stichoza/google-translate-php": "^5.1.3",
        "symfony/process": "^6.4.8",
        "vimeo/laravel": "^5.9",
        "wisdom-diala/countrypkg-laravel": "^1.0.7"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^v2.15.1",
        "beyondcode/laravel-er-diagram-generator": "^2.0",
        "fakerphp/faker": "^1.23.1",
        "laravel/breeze": "^1.29.1",
        "laravel/pint": "^1.16.1",
        "laravel/sail": "^1.30.2",
        "mockery/mockery": "^1.6.12",
        "nonsapiens/realaddressfactory": "^2.0.2",
        "nunomaduro/collision": "^6.4.0",
        "nunomaduro/larastan": "^2.9.7",
        "phpunit/phpunit": "^9.6.19",
        "spatie/laravel-ignition": "^2.8"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "files": [
            "app/Library/helper.php"
        ],
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan filament:upgrade"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Any hints what is wrong and how that can be fixed ?

Additive testing :

After some Additive testing I see that if to comment line :

->live(onBlur: true)

In definition of the first select component I have no this error, but dependecy does not work at all...

1
  • I added Additive testing block
    – mstdmstd
    Commented Jul 11 at 13:09

0

Browse other questions tagged or ask your own question.