There's an issue with Profile2 compatibility, specifically the way Profile2 handles forms. When changing the country field on certain Profile2 forms, ajax doesn't update the form. This is due to the following PHP error.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'profile2_form' not found or invalid function name in drupal_retrieve_form() (line 798 of /includes/form.inc).
By adding a module include for Profile2 in the addressfield.module it appears to fix this. However this approach seems like the proverbial using a "sledgehammer to crack a nut."
<?php
/**
* Implements hook_init().
*/
function addressfield_init(){
if(module_exists('profile2')){
module_load_include('inc', 'profile2', 'contrib/profile2_page');
}
}?>The setup was as follows: I had a Profile2 form with an addressfield in it. When I included the form using the Profile2 approach of "attaching" forms, the ajax changing generated the above error.
Comments
Comment #1
rszrama commentedAs you guessed, this isn't an appropriate fix for Address Field. If I read you right, Profile2 should instead be ensuring its form's build_info array points to the appropriate include file to load when the form gets rebuilt (as it does during this AJAX update request). See for example this code in commerce_product.forms.inc:
Moving this to the Profile2 queue in case it's still an issue. Feel free to close out if you guys already have a fix for this.
Comment #2
rszrama commentedHoly crap, that Profile2 sandbox title is very confusing in the issue tracker. : P