1

I'm trying to add element to user profile form, there is no problem in the registration form but I don't know how to add it in user profile update page

  <div class="col-span-6 sm:col-span-4">
            <x-jet-label for="name" value="{{ __('Name') }}" />
            <x-jet-input id="name" type="text" class="mt-1 block w-full" wire:model.defer="state.name" autocomplete="name" />
            <x-jet-input-error for="name" class="mt-2" />
        </div>
        <!-- Email -->
        <div class="col-span-6 sm:col-span-4">
            <x-jet-label for="email" value="{{ __('Email') }}" />
            <x-jet-input id="email" type="email" class="mt-1 block w-full" wire:model.defer="state.email" />
            <x-jet-input-error for="email" class="mt-2" />
        </div>

I tried to add this but it doesn't work

<div class="col-span-6 sm:col-span-4">
            <x-jet-label for="gender" value="{{ __('Gender') }}" />
            <select id="gender"  class="block mt-1 w-full" name="gender">


                <option value="m" {{ $this->user->gender== 'm' ? 'selected' : '' }} >
                    Male
                </option>
                <option value="f" {{ $this->user->gender== 'f' ? 'selected' : '' }}>
                    Female
                </option>

            </select>
        </div>
2
  • Sorry I forgot wire:model="gender" Commented Feb 17, 2021 at 2:19
  • 1
    Does not work is too vague. Please be more specific about the error. Commented Feb 22, 2021 at 18:05

1 Answer 1

1

Laravel Livewire: Input select, default option selected

Livewire will auto select option, just use wire:model

       <div class="col-span-6 sm:col-span-4">
            <x-jet-label for="gender" value="{{ __('Gender') }}" />
            <select id="gender" class="block mt-1 w-full" wire:model="gender">
                <option value="m">
                    Male
                </option>
                <option value="f">
                    Female
                </option>
            </select>
        </div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.