doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 8 forks source link

Improve front-end form validation feedback #77

Closed gaelpleeroy closed 1 year ago

gaelpleeroy commented 1 year ago

I'm using a frontend form to populate an Address field (https://plugins.doublesecretagency.com/google-maps/address-field/front-end-form/#basic-input-fields)

But when the validation comes I get an error for the global address field, it would be nice that it detects what's missing and adjust the response accordingly. Like [address][city]: "The City is required"

Currently I get the following:

array(1) {
  ["address"]=>
  array(1) {
    [0]=>
    string(93) "The following subfields are required: **Street Address**, **City**, **Zip Code**, **Country**"
  }
}
lindseydiloreto commented 1 year ago

Interesting idea. Your front-end form is using the exact same validation as what you'd see in the control panel.

You're correct, the validation logic currently just compiles a list of all required fields. But perhaps it should only be reporting back the subfields which are required and invalid.

Thanks for the suggestion! 👍

lindseydiloreto commented 1 year ago

Good news, this change has been made in v4.3.3. Thanks again for the great idea!