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

The values for latitude and longitude ("0" and "0") are not valid. #17

Open
florinutz opened this issue Jan 27, 2014 · 7 comments
Open

Comments

@florinutz
Copy link

->add('map_coordinates', 'oh_google_maps', array(
'required' => false,
'lat_name' => 'Latitude',
'lng_name' => 'Longitude'
))

How can I make these REALLY not required?

@florinutz
Copy link
Author

                    ->add('map_coordinates', 'oh_google_maps', array(
                        'required' => false,
                        'map_width' => '90%',
                        'default_lat' => 45,
                        'default_lng' => 25,
                        'lat_name' => 'Latitude',
                        'lng_name' => 'Longitude'
                    ))

this won't work either

@florinutz
Copy link
Author

nor does 'options' => array('required' => false)

@ollietb
Copy link
Owner

ollietb commented Apr 7, 2014

Hi @florinutz Are you getting an error message?

@allo86
Copy link

allo86 commented Nov 19, 2014

I am getting this error message too, but fields are not empty. I am using the map in a Sonata Admin form.

@hisie
Copy link

hisie commented Apr 22, 2015

Is there any new/solution about required false? The error message is The values for latitude and longitude ("0" and "0") are not valid when empty.

@xmon
Copy link
Contributor

xmon commented Jul 17, 2015

Hi, this is my LocationsAdmin.php config

->add('latLng', 'oh_google_maps', array(
                'lat_options' => array(
                    'label' => 'Latitud',
                    'required' => false
                ), // the options for just the lat field
                'lng_options' => array(
                    'label' => 'Longitud',
                    'required' => false
                ), // the options for just the lng field
                'default_lat' => 40.415363, // the starting position on the map
                'default_lng' => -3.707398, // the starting position on the map,
                'required' => false
))

The fields are not required in the form.

When you try to save, with lat and lng fields empty, LatLngValidator addViolation, with this error "The values for latitude and longitude ("0" and "0") are not valid."

If you try to save with 0 in lat and lng fields, works like a charm.

any idea to solve it?

thanks

@xmon
Copy link
Contributor

xmon commented Jul 17, 2015

Hi again,

this "solution" works ok,

->add('latLng', 'oh_google_maps', array(
            'lat_options' => array(
                'label' => 'Latitud',
                'required' => false,
                'data' => 0
            ), // the options for just the lat field
            'lng_options' => array(
                'label' => 'Longitud',
                'required' => false,
                'data' => 0
            ), // the options for just the lng field
            'default_lat' => 40.415363, // the starting position on the map
            'default_lng' => -3.707398, // the starting position on the map,
            'required' => false
))

any comments to improve it?

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

5 participants