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

vincent15000's avatar

Livewire renderless and model alias (Relation::morphMap) don't work for me

Hello,

I want to avoid to render once again a component while some action is triggered.

I have added #[Renderless], but when I have a look at the network tab in the devtools, the update request is triggered. And while closing the modal form, I also see that the fields are emptied, but if #[Renderless] was really applied, I shouldn't see the fields becoming empty.

Furthermore I want to not expose the names of the models, so I wanted to use this from the documentation.

https://livewire.laravel.com/docs/properties#properties-expose-system-information-to-the-browser

public function boot(): void
{
    Relation::morphMap([
        'type' => 'App\Models\Type',
        'user' => 'App\Models\User',
    ]);
}

But in the devtools I still see for example App\Models\Type instead of type.

For example I see this in the devtools.

{
    "App\\Models\\Type": {
        "value": 2,
        "xdebug_link": {
            "url": "phpstorm://open?file=%2Fhome%2Fvincent%2FDocuments%2FPRO%2FDEV%2FPERSO%2Fmentoring%2Fapp%2FModels%2FType.php&line=1",
            "ajax": false,
            "filename": "Type.php",
            "line": "?"
        }
    },
    "App\\Models\\User": {
        "value": 1,
        "xdebug_link": {
            "url": "phpstorm://open?file=%2Fhome%2Fvincent%2FDocuments%2FPRO%2FDEV%2FPERSO%2Fmentoring%2Fapp%2FModels%2FUser.php&line=1",
            "ajax": false,
            "filename": "User.php",
            "line": "?"
        }
    }
}

Who has already used these functionalities and can help me understand how to use them ?

Thanks ;).

V

0 likes
4 replies
tisuchi's avatar

@vincent15000 Maybe you give a try with updating your genderless component like this:

<input {{ $attributes->whereStartsWith('wire:model') }}>
1 like
vincent15000's avatar

@tisuchi What do you mean ?

Hmmm ... here is for example my input component.

@php
    $id = $attributes->whereStartsWith('wire:model')->first() ?? Str::ulid();
@endphp

<div class="flex flex-col gap-1">
    <label for="{{ $id }}" class="italic text-sm text-gray-500">{{ $slot }}</label>

    <input
        {{ $attributes->merge(['class' =>  'transition-all outline-none px-3 py-2 border border-gray-300 focus:border-gray-500 rounded-lg']) }}
        type="text"
        id="{{ $id }}"
    >
</div>

And here the Livewire edit component where I use it.

<div class="flex justify-center">
    <x-ui.form>
        <x:ui.form.input-text wire:model.live="form.name">Nom</x:ui.form.input-text>

        <x-ui.save-cancel></x-ui.save-cancel>
    </x-ui.form>
</div>
tisuchi's avatar

@vincent15000 Thanks for sharing your code.

Can you replace this line:

<input {{ $attributes->merge([...]) }} ...>

With this:

<input {{ $attributes->whereStartsWith('wire:model') }} {{ $attributes->except('wire:model')->merge([...]) }} type="text" id="{{ $id }}">
1 like
vincent15000's avatar

@tisuchi I tried your suggestion, but it doesn't change anything, I still have the same problem.

Please or to participate in this conversation.