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

defaultLocation not modified in edit page or view page #102

Closed
spectra10008 opened this issue May 1, 2024 · 8 comments · Fixed by #118
Closed

defaultLocation not modified in edit page or view page #102

spectra10008 opened this issue May 1, 2024 · 8 comments · Fixed by #118

Comments

@spectra10008
Copy link

Hello ,
i have this issue that defaultLocation not modified to my new location , still marker appear in a default location not my new location that i saved.

@spectra10008
Copy link
Author

Uploading Screenshot 2024-05-01 at 5.22.21 PM.png…

@sstottelaar
Copy link

Did you end up finding a solution?

@sstottelaar
Copy link

I ended up needing this on my model:

protected $appends = [
      'location',
  ];

@amrmsccs
Copy link

@sstottelaar Did you guys find any solution?

@amrmsccs
Copy link

I ended up needing this on my model:

protected $appends = [
      'location',
  ];

Didn't work with me still getting error location is not afield in your database.
Hope someone got solution.

@ryanmortier
Copy link
Contributor

Same issue :(

@ryanmortier
Copy link
Contributor

ryanmortier commented Aug 27, 2024

Until that is merged, if anyone is looking for a quick fix then extend the component and put that fix in. Remember to change your form field to use your class.

<?php

namespace App\Forms\Components;

use Exception;

class Map extends \Cheesegrits\FilamentGoogleMaps\Fields\Map
{
    public function getState(): mixed
    {
        $state = parent::getState();

        if (is_array($state)) {
            if (empty(array_filter($state))) {
                return $this->getDefaultLocation();
            }

            return $state;
        } else {
            try {
                return @json_decode($state, true, 512, JSON_THROW_ON_ERROR);
            } catch (Exception $e) {
                return $this->getDefaultLocation();
            }
        }
    }
}

@Heyian
Copy link
Collaborator

Heyian commented Aug 28, 2024

Hey there. I've merged the PR associated with this issue onto my fork so we can all get all these goodies from a single place. I gave credits to the person who made the PR in the commits, changelog and in the releases.
I've also credited cheesegrits for his work on the repo and made it clear this was a fork on top of the Readme. I'm not trying to hijack anything, I just want to be able to use all the good solutions people put in the pull requests and I thought I'd made this available to all. If you're interested in this version or want to contribute, you can find my fork at : Heyian/forkMain

I'm open to suggestions on how to move forward from here, simply open up an issue in my fork so we can chat about it.
Thanks.

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

Successfully merging a pull request may close this issue.

5 participants