© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•15mo ago•
4 replies
Mark

How can I access component properties in view?

I'm trying to create a custom field using the following code:
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\Field;

class SelectWithPivot extends Field
{
    protected string $view = 'forms.components.select-with-pivot';

    public ?int $selectedItem = null;

    protected function setUp(): void
    {
        parent::setUp();

        $this->afterStateHydrated(function (self $component, ?array $state) {
            if (blank($state)) {
                $component->state(['test' => 1]);
            }
        });
    }

    public function updatedSelectedItem()
    {
        dd($this->selectedItem);
    }
}
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\Field;

class SelectWithPivot extends Field
{
    protected string $view = 'forms.components.select-with-pivot';

    public ?int $selectedItem = null;

    protected function setUp(): void
    {
        parent::setUp();

        $this->afterStateHydrated(function (self $component, ?array $state) {
            if (blank($state)) {
                $component->state(['test' => 1]);
            }
        });
    }

    public function updatedSelectedItem()
    {
        dd($this->selectedItem);
    }
}


Now I want to use the
$selectedItem
$selectedItem
property in my blade (
wire:model
wire:model
):

<x-dynamic-component
    :component="$getFieldWrapperView()"
    :field="$field"
>
    {{ json_encode($getState()) }}
    <div x-data="{ state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$getStatePath()}')") }} }">
        <select wire:model="selectedItem">
            <option>1</option>
            <option>2</option>
            <option>3</option>
        </select>
    </div>
</x-dynamic-component>
<x-dynamic-component
    :component="$getFieldWrapperView()"
    :field="$field"
>
    {{ json_encode($getState()) }}
    <div x-data="{ state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$getStatePath()}')") }} }">
        <select wire:model="selectedItem">
            <option>1</option>
            <option>2</option>
            <option>3</option>
        </select>
    </div>
</x-dynamic-component>


But I get this error:
Livewire: [wire:model="selectedItem"] property does not exist on component: [app.domains.relations.filament.resources.relation-resrouce.relation-managers.packages-relation-manager]
Livewire: [wire:model="selectedItem"] property does not exist on component: [app.domains.relations.filament.resources.relation-resrouce.relation-managers.packages-relation-manager]


What am I doing wrong? It seems the view is looking at the parent component or something?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How can I access viewData variables in a view using Alpine.js?
FilamentFFilament / ❓┊help
17mo ago
how use viewData value at ViewField in the blade view
FilamentFFilament / ❓┊help
3y ago
How can I customise the view of a ViewAction?
FilamentFFilament / ❓┊help
3y ago
How can i publish view component that comes from filament ?
FilamentFFilament / ❓┊help
2y ago