ollietb / OhGoogleMapFormTypeBundle

Set latitude and longitude values on a form using Google Maps
MIT License
30 stars 76 forks source link

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

Open florinutz opened 10 years ago

florinutz commented 10 years ago

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

How can I make these REALLY not required?

florinutz commented 10 years ago
                    ->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 commented 10 years ago

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

ollietb commented 10 years ago

Hi @florinutz Are you getting an error message?

allo86 commented 9 years ago

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

hisie commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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?