Closed (fixed)
Project:
Profile2 Registration Path
Version:
7.x-1.9
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 May 2012 at 12:22 UTC
Updated:
3 Sep 2012 at 10:44 UTC
There is a problem with the way profile2_regpath attaches fields to user register form.
One case is described here http://drupal.org/node/1440738#comment-5993478 but I think that a lot of situations where the form is altered through AJAX may experience this kind of annoyances. The effect is that after adding or removing fields to the form dynamically you can loose all the 'profile section' of the form array. The source of the problem is in the way _get_profile_types_by_path() works. In the above described situations it returns nothing
function profile2_regpath_form_alter(&$form, &$form_state, $form_id) {
// Check to see if we're building this form for a block.
if (strpos($form_id, 'profile2_regpath_form_block_') === 0) {
$profile_types = profile2_regpath_get_profiles(NULL, NULL, $form_state['profile_type_id']);
profile2_regpath_attach_profile_fields($form, $form_state, $form_id, $profile_types);
}
elseif ($form_id == 'user_register_form') {
// Get profile2 profile types from current path.
$profile_types = _get_profile_types_by_path();
profile2_regpath_attach_profile_fields($form, $form_state, $form_id, $profile_types);
}
}We should find a more robust way that succeeds in managing these situations.
Comments
Comment #1
tcalin commentedHere is a quick fix that works for me.
I get the profile based on path taken from form's action (The two lines of code above the last commented line).
Comment #2
grasmash commentedThanks for noticing this.
I've made the change that you requested to the dev versions. Additionally, I've used the same method in profile2_regpath_attach_profile_fields(), removing the need for _get_profile_types_by_path() altogether.
I like this method because it actually reduces the number of database queries. I can't see any issues with it at the moment, but I'm doing to leave it in dev for a bit -- dealing with AJAX requests in combination with various path-generation methods has really been the main challenge with this module.
Comment #3
grasmash commentedGoing to change this to fixed. Try out dev and let me know if you have any problems.
Comment #4
tcalin commentedIt works!
No problems until now.
Thanks for pushing this to the dev!
Comment #6
pritam-osl commentedwaaaw...It saved my time