Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateRangePicker on Laravel Vue Not Setting Value to Vue Model #23

Open
geraldmacasaet opened this issue Oct 21, 2023 · 1 comment
Open

Comments

@geraldmacasaet
Copy link

I tried using the DateRange Picker in my LaraVue project but I just can't seem to get the value of the datepicker to my vue model.

<div>
  <InputLabel value="Select Date" class="mb-1" />
   <div date-rangepicker id="dateRangePickerId" class="inline-flex items-center w-full">
     <div class="relative w-full">
        <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
            <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true"  xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
                     <path
                                            d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" />
                                    </svg>
                                </div>
                                <input type="text" datepicker-autohide v-model="form.when_start"
                                    :class="form.errors.when_start ? 'border-red-500' : ''"
                                    class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-[#0032A0] focus:border-[#0032A0] block w-full pl-10 p-2.5  dark:bg-transparent dark:border-gray-400 dark:placeholder-gray-400 dark:text-white dark:focus:ring-[#0032A0] dark:focus:border-[#0032A0]"
                                    placeholder="Select date start">
                            </div>
                            <span class="mx-4 text-gray-500">to</span>
                            <div class="relative w-full">
                                <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
                                    <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true"
                                        xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
                                        <path
                                            d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" />
                                    </svg>
                                </div>
                                <input type="text" datepicker-autohide v-model="form.when_end"
                                    :class="form.errors.when_end ? 'border-red-500' : ''"
                                    class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-[#0032A0] focus:border-[#0032A0] block w-full pl-10 p-2.5  dark:bg-transparent dark:border-gray-400 dark:placeholder-gray-400 dark:text-white dark:focus:ring-[#0032A0] dark:focus:border-[#0032A0]"
                                    placeholder="Select date end">
                            </div>
                        </div>
                        {{ form.when_start }}
                        {{ form.when_end }}
                        <InputError :message="form.errors.when_start" />
                        <InputError :message="form.errors.when_end" />
                    </div>

Any workaround?

@Bruck-3
Copy link

Bruck-3 commented Jan 28, 2024

you can use the ref property. something like this
input ref="datepicker"
then
this.$refs.datepicker.value will get you the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants