OhGoogleMapFormTypeBundle icon indicating copy to clipboard operation
OhGoogleMapFormTypeBundle copied to clipboard

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

Open florinutz opened this issue 11 years ago • 7 comments

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

How can I make these REALLY not required?

florinutz avatar Jan 27 '14 16:01 florinutz

                    ->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 avatar Jan 27 '14 16:01 florinutz

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

florinutz avatar Jan 27 '14 17:01 florinutz

Hi @florinutz Are you getting an error message?

ollietb avatar Apr 07 '14 10:04 ollietb

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

allo86 avatar Nov 19 '14 15:11 allo86

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.

hisie avatar Apr 22 '15 15:04 hisie

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 avatar Jul 17 '15 16:07 xmon

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?

xmon avatar Jul 17 '15 16:07 xmon