I'm making a clients profile and a customers profile. Set up all the fields in Clients and cloned it, changed the name to Customers and thought that when I went in to manage fields, the ones from the client profile would be there but it only had 'Add new field' and 'Add existing field' without the other fields that were in the client profile. I'm pretty new to Drupal so perhaps they shouldn't have been copied. Please put me right if this is the case! :)
Comments
Comment #1
scanmaster commentedSays this after cloning: Notice: Trying to get property of non-object in profile2_page_own_title()
Comment #2
zkday commentedYes,
I'm working in my project and i have a patch for this issue.
Comment #3
zkday commentedsee issue #1210620 at http://drupal.org/node/1210620
Comment #5
zkday commentedwaiting issue #1210620 at http://drupal.org/node/1210620 is resolved, and re-test #2 patch.
Comment #6
zkday commented#2: 1317446-Cloning_a_profile_type_with_field_api.patch queued for re-testing.
Comment #8
zkday commentedAttach patch!
Comment #10
zkday commented#8: profile2-cloning_a_profile_type_with_field_api-1317446.patch queued for re-testing.
Comment #12
fraweg commentedHello,
is this issue solved?
Best regards
Frank
Comment #13
zkday commentedUpdate patch for new dev version ;)
p.s:
@fraweg: I'm working for this issue with my customer. You can test and reviews this patch. ;)
Comment #15
fraweg commentedHello zkday,
thanks for yor work! This patch does noct change this problem on my system. I had test it with the stable and the dev-version.
Best regards
Frank
Comment #16
zkday commentedHi fraweg,
I was reapply the patch in #13 and retest on my system. This has working for this problem ;).
please reapply the patch in #13 for dev-version, and you retest it. ;)
Thanks,
Comment #17
slashzero commentedThank, the patch in #13 worked for me and saved the day!
Comment #18
fraweg commentedHi,
Thanks for your work. I will test it the next days...
Best regards
Frank
Edit: The patch #13 does not work for me with 7.x-1.2 . Have I to use the dev version?
Comment #19
devilworks commentedPatch #13 worked.
Thanks
Comment #20
zkday commentedComment #21
Bronislovas commentedTried #13 patching by hand. Works great! Profile2 version 7.x-1.2
Comment #22
areynolds commentedMy testing indicates the patch doesn't work. A quick look at the debugger makes it appear that the anticipated bundle machine name value ($profile_type_source->type) is not correctly populated (I see a boolean, not a string).
$instances = field_info_instances('profile2', $profile_type_source->type);Tested with both 7.x-1.2 and 7.x-dev.
Comment #23
zkday commented@areynolds, thank you for reviews!
In later version of entity module, function
entity_ui_clone_entityis called when 1 entity is cloned, that is reset {KEY_NAME} of entity is FALSE, I will fix this bug in later.Comment #24
zkday commentedThis feature need support in entity, and this is issue: #1513812: When cloning entity, fields are not cloned
Comment #25
areynolds commentedThanks @zkday!
Comment #26
hobbes_vt commented13: Cloning_a_profile_type_does_not_copy_the_fields-1317446.patch queued for re-testing.
Comment #27
klonos...accidental edit?
Comment #28
hobbes_vt commentedYes, sorry - seem to never have hit submit my original post. I meant to report that it worked for me when I applied the patch a week ago. Strangely enough it seems not working any more. One of the core things changed in my installation was the update to drupal core 7.24 - not sure if this has to do anything with it, but I'm afraid I don't have the time to investigate this too much further and will simply re-create profiles instead of using the cloning option.
Comment #29
hobbes_vt commentedThe entity patch posted in https://drupal.org/node/1513812 #23 did the trick for my latest configuration - thanks for the work fixing this - very much appreciated!
Comment #30
DrSage commentedSo I faced with same problem, patch is not work anymore when I'm trying to clone Profile.
So I updated code to make it work.
For me it's work with 1.6 version, also it's clone group pseudo fields.
function profile2_type_form($form, &$form_state, $profile_type, $op = 'edit') {
if ($op == 'clone') {
$form_state['profile_type_source'] = clone $profile_type;
$form_state['bundle_source'] = arg(4);
$profile_type->label .= ' (cloned)';
$profile_type->type = '';
}
function profile2_type_form_submit(&$form, &$form_state) {
$form_state['values']['data']['roles'] = array_filter($form_state['values']['data']['roles']);
$profile_type = entity_ui_form_submit_build_entity($form, $form_state);
// Save and go back.
$profile_type->save();
if (isset($form_state['bundle_source']) && isset($profile_type->id)) {
$bundle_source = $form_state['bundle_source'];
$instances = field_info_instances("profile2", $bundle_source);
foreach ($instances as $field_instance) {
$field_instance['bundle'] = $profile_type->type;
$field = field_create_instance($field_instance);
}
// Integrate with the field_group module.
if (module_exists('field_group')) {
$groups = field_group_info_groups("profile2", $bundle_source, 'form', TRUE);
foreach ($groups as $group) {
$group->bundle = $profile_type->type;
ctools_export_crud_save('field_group', $group);
}
}
}
$form_state['redirect'] = 'admin/structure/profiles';
}
Comment #31
rickj commentedThis issue is closed, as the solution is in the Entity module.
The patch in this issue (comment #67) resolves the problem.
Apply that patch to Entity and profiles will clone correctly.