© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
3 replies
Jerome V

Cannot store select options data in another table

Good day, in some modules it's working... but in this module is not working,, I want to add gender of the user but the userDetails is separate from users table

code

Resource
  Forms\Components\Select::make('detail.gender')
                                    ->label('Gender')
                                    ->required()
                                    ->options(Gender::array())
                                    ->placeholder('Select Gender'),
  Forms\Components\Select::make('detail.gender')
                                    ->label('Gender')
                                    ->required()
                                    ->options(Gender::array())
                                    ->placeholder('Select Gender'),


user model
 public function detail(): HasOne
    {
        return $this->hasOne(UserDetail::class, 'id');
    }
 public function detail(): HasOne
    {
        return $this->hasOne(UserDetail::class, 'id');
    }


UserDetail

<?php

namespace App\Models;

use App\Cache\UserDetail\UserDetailById;
use App\Enums\UserDetail\Gender;
use App\Models\Contracts\Cacheable;
use App\Observers\UserDetailObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[ObservedBy([UserDetailObserver::class])]
class UserDetail extends Model implements Cacheable
{
    use HasFactory;

    protected $fillable = ['birthdate','gender'];

    protected function casts(): array
    {
        return [
            'birthdate' => 'date',
            'gender' => Gender::class,
        ];
    }

    public function clearCache(): void
    {
        (new UserDetailById($this->id))->invalidate();
    }
}
<?php

namespace App\Models;

use App\Cache\UserDetail\UserDetailById;
use App\Enums\UserDetail\Gender;
use App\Models\Contracts\Cacheable;
use App\Observers\UserDetailObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[ObservedBy([UserDetailObserver::class])]
class UserDetail extends Model implements Cacheable
{
    use HasFactory;

    protected $fillable = ['birthdate','gender'];

    protected function casts(): array
    {
        return [
            'birthdate' => 'date',
            'gender' => Gender::class,
        ];
    }

    public function clearCache(): void
    {
        (new UserDetailById($this->id))->invalidate();
    }
}
Solution
you should do this if you are using a single relationship
Managing relationships - Panel Builder - Filament
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Update Table Data from Form Select Options
FilamentFFilament / ❓┊help
3y ago
Store data to pivot table
FilamentFFilament / ❓┊help
3y ago
Form select not updating options data
FilamentFFilament / ❓┊help
2y ago