© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
Gleb <Sclif> Kolesnikov

make reactive custom field options

Hello everyone, i have custom form field with options
S3Uploader::make('url')
                          ->folder('music')
                          ->bucket(fn() => $form->bucket ?? 'private')
                          ->entityId(fn()=>$form->getRecord()?->id ?? $id)
                          ->columnSpanFull()
S3Uploader::make('url')
                          ->folder('music')
                          ->bucket(fn() => $form->bucket ?? 'private')
                          ->entityId(fn()=>$form->getRecord()?->id ?? $id)
                          ->columnSpanFull()

S3Uploader

class S3Uploader extends Field
{
    use HasHelperText;

    protected string $view = 'forms.components.s3-uploader';

    protected ?bool $isLive = true;

    protected string | \Closure | null $bucket = 's3_public';
    protected string | \Closure | null $folder = '/';
    protected string | \Closure $entityId;

    public function updateBucketType($bucketType): void
    {
        $this->bucket = $bucketType;
    }


    public function bucket($bucket) : static
    {
        $this->bucket = $bucket;

        return $this;
    }

    public function entityId($id) : static
    {
        $this->entityId = $id;

        return $this;
    }

    public function getEntityId() : string
    {
        return $this->evaluate($this->entityId);
    }

    public function getBucket(): ?string
    {
        return  $this->evaluate($this->bucket);
    }

    public function folder($folder) : static
    {
        $this->folder = $folder;

        return $this;
    }

    public function getFolder(): ?string
    {
        return  $this->evaluate($this->folder);
    }
}
class S3Uploader extends Field
{
    use HasHelperText;

    protected string $view = 'forms.components.s3-uploader';

    protected ?bool $isLive = true;

    protected string | \Closure | null $bucket = 's3_public';
    protected string | \Closure | null $folder = '/';
    protected string | \Closure $entityId;

    public function updateBucketType($bucketType): void
    {
        $this->bucket = $bucketType;
    }


    public function bucket($bucket) : static
    {
        $this->bucket = $bucket;

        return $this;
    }

    public function entityId($id) : static
    {
        $this->entityId = $id;

        return $this;
    }

    public function getEntityId() : string
    {
        return $this->evaluate($this->entityId);
    }

    public function getBucket(): ?string
    {
        return  $this->evaluate($this->bucket);
    }

    public function folder($folder) : static
    {
        $this->folder = $folder;

        return $this;
    }

    public function getFolder(): ?string
    {
        return  $this->evaluate($this->folder);
    }
}


and standart field in same form

Select::make('bucket')
                      ->required()
                      ->live()
                      ->afterStateUpdated(
                          function($state, callable $set) use ($form) {
                              //some code here?
                          }
                      )->options(['public','private'])
Select::make('bucket')
                      ->required()
                      ->live()
                      ->afterStateUpdated(
                          function($state, callable $set) use ($form) {
                              //some code here?
                          }
                      )->options(['public','private'])


i want reactive change bucket attribute dependend on $state of Select::make('bucket'), how i may make this.
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

Reactive Builder field
FilamentFFilament / ❓┊help
3y ago
reactive field for collections
FilamentFFilament / ❓┊help
3y ago
Make Relation Manager reactive?
FilamentFFilament / ❓┊help
3y ago
Make Text Input Reactive
FilamentFFilament / ❓┊help
3y ago