Files
livewire-material/tests/Feature/Components/PlainFormErrorsTest.php
T
Andreas Reinhold / reiniandClaude Opus 5 648a4cfe0f
tests / lint (push) Successful in 1m5s
tests / feature (8.4) (push) Successful in 1m9s
tests / feature (8.5) (push) Successful in 1m9s
tests / browser (chrome, chromium) (push) Successful in 3m19s
tests / browser (safari, webkit) (push) Successful in 5m0s
tests / browser (firefox, firefox) (push) Successful in 4m34s
Show a plain form field's errors under its name
Fields read their errors only under the wire:model name, so a Fortify
login form (name="email", no wire:model) never showed "These
credentials do not match". Without wire:model they now read the name,
turning brackets into dots.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
2026-09-13 10:41:37 +02:00

25 lines
1.4 KiB
PHP

<?php
it('shows the errors of a plain form field under its name', function (string $blade, string $key) {
$html = (string) $this->withViewErrors([$key => ['Something is wrong here.']])->blade($blade);
expect($html)
->toContain('Something is wrong here.')
->toContain('aria-invalid="true"');
})->with([
'input' => ['<x-input name="email" label="Email" />', 'email'],
'password' => ['<x-password name="password" label="Password" />', 'password'],
'textarea' => ['<x-textarea name="message" label="Message" />', 'message'],
'select' => ['<x-select name="hours" label="Expires" :options="[[\'id\' => 1, \'name\' => \'1 hour\']]" />', 'hours'],
'checkbox' => ['<x-checkbox name="terms" label="Terms" />', 'terms'],
'radio' => ['<x-radio name="audience" :options="[[\'id\' => \'a\', \'name\' => \'A\']]" />', 'audience'],
'file with brackets' => ['<x-file name="photos[]" label="Photos" multiple />', 'photos'],
'nested name' => ['<x-input name="address[city]" label="City" />', 'address.city'],
'timepicker' => ['<x-timepicker name="starts_at" label="Starts at" />', 'starts_at'],
]);
it('keeps reading the wire:model name when both are there', function () {
expect((string) $this->withViewErrors(['form.email' => ['Taken.']])->blade('<x-input name="email" wire:model="form.email" label="Email" />'))
->toContain('Taken.');
});