Can you show the function inside which you have the different $this->reset...(); lines please ?
Form validation errors not clearing on updating value
We have a select element in a Livewire 3 component which has the attribute in the controller:
#[Validate('required|numeric')]
public $appt_type;
And this in the blade file:
<select name="appt_type" id="appt_type"
wire:model.live="appt_type"
wire:change="setEndTime"
class="py-1 px-2 pr-5 block w-full text-gray-700 border-gray-200 rounded-md focus:border-blue-500 focus:ring-blue-500">
<option value="" selected>Select a type...</option>
@foreach ($services as $service)
<option value="{{ $service->ID }}">{{ $service->own_description }}</option>
@endforeach
</select>
@error('appt_type') <span class="err-message">{{ $message }}</span> @enderror
<x-input-error :messages="$errors->get('appt_type')" class="mt-2" />
(I know there are two error displays above, they are there for testing.) If element doesn't have a value selected and the form containing the element is submitted I (correctly) get an error: "The appt type field is required."
However, if the value is then updated, the error message doesn't clear, even though the form will subsequently submit successfully. The display of the error persists even after the form has the followed called on submission:
$this->reset();
$this->resetErrorBag();
$this->resetValidation();
If I examine the response from the server after updating the value of the select element, and it doesn't contain any error messages \"errors\":[],, so I'm assuming that the client side isn't updating. Am I missing something I should be including to make these errors clear when value is updated or the form is reset?
For anyone else who is having this issue, I finally found the cause. I had wire:transition on an element in another Livewire component on the page. According to the Livewire docs that has to be used within a Blade conditional and that wasn't how it was being used...
Please or to participate in this conversation.