Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Cee_Bee's avatar

Modelable Issues with Parent Child Components

I am trying to create some reusable component with three MaryUI Select components (MaryUI isn't the issue). Source, Status and Owner. From the parent Livewire page I pull possible existing Source Status or Owner if we are viewing the object or leave as blank if we are creating. The issue is where we have a blank Source or Status for example and we have a default value set from the database. User is set on the parent ownerId and works with preselecting the correct user. In the child Livewire component I am doing the following to get the default value but the issue is the parent overwrites the found default value with in my case an empty string.

I did a test where I hard coded statusId in the parent and it populated correctly. It seem there's something that will always override the child property even if the parent property is null/ empty. Is there a work around? I know I can use events and such but that seems hacky! The reason I want it to work like this is that these three inputs are used a lot over the system I am making and not ideal to duplicate the same methods and such possibly 7 or 8 times each.

Parent Class, removed unrelated code:

Main Blade:

@props([
    'object' => 'contact'
])

<div>
    <livewire:components.ui.source :object="$object" wire:model="sourceId" />
    <livewire:components.ui.status :object="$object" wire:model="statusId" />
    <livewire:components.ui.owner :object="$object" wire:model="ownerId" />
</div>

Livewire View:

<div>
    <x-ui.field required>
        <x-ui.label>Status</x-ui.label>
        <x-mary-choices-offline
            class="rounded-box"
            wire:model="statusId"
            :options="$statuses"
            placeholder="Select a status..."
            clearable
            searchable
            single
        />
    </x-ui.field>
</div>

0 likes
1 reply

Please or to participate in this conversation.