//check a branch doesnt already exist for this Member, as they are only allowed one branch per login
user_error('Only one branch is allowed per franchisee', E_USER_ERROR);
//get the lat long details if not present
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=".urlencode($this->getFullAddressMAPAPI()).",GB&sensor=true";
$geocode = json_decode(file_get_contents($url));
$geo = $geocode->results->geometry->location;
$this->MapLat = $geo->lat;
$this->MapLong = $geo->lng;
However this just throws the black box in the top right with a php error, rather than a nice warning to the user that they can do what they are trying to do.
Any ideas on how to show a friendly error and stop the process in this instance?
I think that generating a user error as a form validation method isn't the best way to tackle this, as you basically just stop execution... Maybe you could use a validator instead? Or disable the option beforehand (including some description) if a branch already exists for that user?
But on second thought the best option is probably the second. Maybe just set canCreate for the branch to false if a branch already exists for that member. That should remove the add button if all goes well, and still allow the user to edit the existing (i don't know how you've implemented things, but that should be the general gist of it...