victorybiz / laravel-tel-input

Laravel Telephone Input component for Blade and Livewire based on the intl-tel-input JavaScript plugin.
https://github.com/victorybiz/laravel-tel-input
MIT License
40 stars 13 forks source link

I am using a livewire component but i am not able to populate data in the fields and in the flags as well #22

Open itsnoman opened 1 year ago

itsnoman commented 1 year ago

Here is my PHP class code. public function mount() { $this->data['country_code'] = str_replace("+","",optional(user())->country_code); $this->data['phone_no'] = str_replace(optional(user())->country_code,'',optional(user())->phone_no); $this->data['full_no'] = optional(user())->phone_no; }

Here is my livewire blade component ` <x-tel-input wire:model="data.phone_no" id="phone" name="phone" class="form-input" />

`

Khadreal commented 2 months ago

Having a similar issue, when the form is submitted to the livewire component, I'm getting empty for the model. were you able to resolve this ? @itsnoman

@victorybiz please any idea why this might be happening ? Here is a snippet

Blade

<x-tel-input
            wire:model.live="phone"
            value="{{ $number }}"
            id="phone"
            name="phone"
            class="form-input"
        />
        <input wire:model="phone_country" type="hidden" id="phone_country" name="phone_country">

Component

public function save()
    {
        $this->validate();

        var_dump($this->phone); var_dump($this->phone_country);// this is returning empty string
        $this->successMessage = 'Thank you for this';

        //Clear fields
        $this->reset(['number', 'message']);
        //return links preview link and shortlink option
    }