maDE's avatar
Level 1

LV8 jetstream /register: set default value from get-parameter

Hi,

i added a new field to the register form:

            <div class="mt-4">
                <x-jet-label for="code" value="{{ __('Invite Code') }}" />
                <x-jet-input id="code" class="block mt-1 w-full" type="text" name="code" :value="old('code')" required />
            </div>

Now i need an easy solution for set the deafult value from a get parameter: https://domain.tld/register?code=1234

I tried this without success:

 :value="old('code', '{{ app(\'request\')->input(\'code\') }}')"

What is the perfect way here?

best regards, daniel.

0 likes
3 replies
thewebartisan7's avatar
Level 14

Inside component prop :value don't use {{ }}

 :value="old('code', request()->get('code'))"
Snapey's avatar

Why do you need to ask the user for the code (via input) if you are going to pass it to the form? You could create a hidden field or add the code to the form query string?

maDE's avatar
Level 1

Inside component prop :value don't use {{ }}

:value="old('code', request()->get('code'))"

Thanks! works perfect.

Why do you need to ask the user for the code (via input) if you are going to pass it to the form? You could create a hidden field or add the code to the form query string?

because that is the functionality i need.

give the code via url is only additional service.

Please or to participate in this conversation.