SQLSTATE[HY000]: General error: 1364 Field 'locked' doesn't have a default value

I have created my Filament page settings, the settings table in my database has been created successfully, I have added the initial data. The data is displayed correctly within Filament, but at save time the following error is thrown: SQLSTATE[HY000]: General error: 1364 Field 'locked' doesn't have a default value. Any idea why this error happens?
5 Replies
toeknee
toeknee2y ago
You have not passed a value for ''locked' and locked does not have a default value. in the model use attributes to define the default or set the default on the table
uicabpatweyler
uicabpatweylerOP2y ago
And how could I add it from Filament? Since filament gets the data to display and update from the configuration file defined in protected static string $settings = GeneralSetting::class; In this case the properties are in the GeneralSettings.php file. And each field corresponds to the name of a property. In my case I have these: <?php namespace App\Settings; use Spatie\LaravelSettings\Settings; class GeneralSetting extends Settings { public string $app_name; public string $organization_name; public string $organization_description; public int $school_cycle_current; public static function group(): string { return 'generalSetting'; } } The name of each form field must correspond with the name of the property on your settings class. The form will automatically be filled with settings from the database, and saved without any extra work.
FullyLoadedTech
I had this problem. Had to both run migration and re-import Spatie Settings config due to new package version 3.0. This fixed the lock error as well as duplicate settings records being created.
buzkall
buzkall2y ago
In case someone else has this problem, here is the Spatie's upgrade guide to settings v3. -> https://github.com/spatie/laravel-settings/blob/main/UPGRADING.md The main part to avoid the duplication of settings is the unique key in the migration!
GitHub
laravel-settings/UPGRADING.md at main · spatie/laravel-settings
Store strongly typed application settings. Contribute to spatie/laravel-settings development by creating an account on GitHub.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server