Closed (fixed)
Project:
Profile
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Jun 2016 at 13:09 UTC
Updated:
22 Sep 2020 at 20:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
nedjoThanks for submitting your suggestion.
Please see documentation on patches for how to produce a patch file in unified diff format. If you give your file a .patch extension, you'll be able to attach it in a form that's much easier to review.
Also, it helps a lot if you provide details about what issue you're addressing and exactly why you're proposing the specific changes. See the issue summary template.
Some quick comments:
No need to put your user name here. If something isn't needed you should simply delete it in a patch rather than commenting out. But presumably there's a reason for the weighting, so if you're removing it it's important to explain why (in the issue summary).
Again, thanks for contributing!
Comment #3
abhaysaraf commentedComment #4
abhaysaraf commentedI have updated the file with proper reasons of removing $weight from the profile.module file.
I used a web tool to quickly prepare diff file, and username at the code comment(which was actually for my internal debugging) has wrongly appeared in the file and has been removed.
Also, next time I will take care of all the suggestions you mentioned. Thanks.
Comment #5
dakala@abhaysaraf: Please see https://www.drupal.org/patch for how to create a patch as @nedjo has suggested. It's a file with .patch extension that should be attached to this issue.
Comment #6
guttenbergovitz commentedmade a patch out of the file but it doesn't seem to work...
Comment #7
mglamanOkay, I see. The problem here is that the injected fields are not on the form display and they can't be moved around in relation to the normal fields on the form.
Need spaces after
//Also.. the latter half can just be removed.
Comment #8
michiellucas commentedThis is still a problem, on user/%/edit pages the profile fields are not shown.
Comment #9
michiellucas commentedI created a patch that uses a form_alter (like the user register) to add the profile fields to the edit form with the active profile types prefilled.
Comment #10
maaty388 commentedI made some code style fixes :)
Comment #11
jwilson3There's a related issue #2946670: Add computed {$profile_type}_profiles fields to users, use them to render profile data on the user profile which takes an approach written by Matt for another ticket to get the injected profile field working on the "Manage Display" tab of user entity.
Comment #12
geek-merlinWow, this issue looks quite confused to me. The only reasonable approach is #6 and no form alter is needed then.
Comment #13
geek-merlinPatch flying in that worksforme.
Comment #15
geek-merlinUps, missed some leftovers. Here we go.
Comment #17
geek-merlinAh, i adjusted the form keys to use a allowed namespace, thus fixed tests.
Comment #18
geek-merlinOK, it looks like in the test, without a configured user form display, the form does not appear. What is to be expected if the patch succeeds. Will fix the test later.
Comment #19
geek-merlinLet's move the form key namespace fix to a followup. Added a needed cache reset on profile type save.
Comment #20
imclean commentedWith this patch the profile now appears in "manage form display" at
/admin/config/people/accounts/form-displaybut this doesn't affect the user edit form ("user_form"). #9 mentioned this and while it might seem like a separate fix, it means the form display modes only apply to the user registration form and not the user edit form, which is a bit confusing.The profile currently appears as a separate tab on the user edit form but this doesn't reflect the user account settings.
Comment #21
imclean commentedThis combines #9 with #19 to provide consistency between the user edit and create forms.
Comment #22
zenimagine commentedI am lost with all these question and different patch.
I used this patch that will work :
https://www.drupal.org/project/profile/issues/2946670#comment-12640613
Now I deleted it and applied the patch #21
But you can not get the ID of the profile.
There is even more formatting options for the field.
I used in the twig of my template :
But it does not work anymore with this patch. How can I get the profile ID ?
With the old patch, it works :
https://www.drupal.org/project/profile/issues/2946670#comment-12640613
Comment #23
simon georges commentedThe patch in #21 is incorrect because the extra-field bit is not inside the foreach, and therefore generates 500 errors when installing the module.
Comment #24
simon georges commentedThis should be the correct patch. Credits to previous contributors, I just moved the code at the right place.
Comment #25
lee luyanda commentedThanks to all contributors of this feature patch it worked for me here https://www.hookupndate.com before it my custom profile registration fields showed below the email field and username field now I have control.
Comment #26
grn commentedYes, thank you all. It's a very nice feature. I was just wondering if this patch could have anything to do with this bug: https://www.drupal.org/project/multiple_registration/issues/3036696
Thanks!
Comment #27
amourowWhen profile specified for Allowed roles in
/admin/config/people/profiles/manage/[profile_name]The profile form show in user edit form anyway even it is not an allowed role.
For example, there are profile_a and profile_b,
and profile_a allowed role_a to have this profile,
while profile_b only allowed role_b to have it.
However, both profile_a and profile_b show in the user edit form.
Comment #28
bojanz commentedThere is no such thing as a critical feature request.
Comment #29
scottsawyer@amourow, I think you are correct, there should be a check in the form alter that checks whether the current user has permission to update the profile before it is displayed.
In the patch in #24:
Possibly do something like this:
So, basically get the current user, and check if they have update permission before added to the form. Though, I am thinking this might require some massaging of profile_form_user_registration_form(). Should we also be checking for 'create' and 'delete' permissions?
Thoughts?
Comment #30
scottsawyerHm, thinking about this a bit more, if we need the $profiles to be passed to profile_form_user_registration_form_alter, we might need to set it up a bit differently.
I am not sure this is the best way to handle it, I don't like assigning $registration_form_state, then possibly reassigning it to $form_state. I think it will do what we need.
Honestly, I am not sure why we're checking $profile_type->getRegistration() here. Maybe I don't understand how that plays into whether or not a user can edit a profile.
Comment #31
scottsawyerWell, the patch doesn't apply to the latest dev (dev-1.x 6ab5cb0). I don't have time to re-roll at the moment.
Comment #32
jonathanshawComment #33
bojanz commentedComment #34
jsacksick commentedThe attached patch provides a field widget for the computed field that was added as part of #2946670: Add computed {$profile_type}_profiles fields to users, use them to render profile data on the user profile.
There's a post update function that is in charge of placing the computed field on the user "register" form mode if the "Include in user registration form" profile type setting is checked.
The widget should also support editing the default profile.
I added some code to react when the "Include in user registration form" setting is updated. If it's unchecked, the computed field is removed from the form mode, otherwise it's placed at the bottom.
Comment #36
jsacksick commentedComment #38
jsacksick commentedAttempt to fix the tests, sorry for the noise.
Comment #39
jsacksick commentedAdding a "form_mode" widget setting and removing the revision log message in preparation for when #2844963: Complete the revision implementation is committed.
Comment #40
jsacksick commentedAttaching the interdiff.
Comment #42
jsacksick commentedRerolled the patch.
Comment #43
bojanz commentedUpdating title and issue summary.
Comment #44
bojanz commentedHere is a reroll with some small cleanups (such as a rewritten profile_post_update_configure_register_form_mode()).
Comment #45
jsacksick commentedI copied the Field group code we had in the form alter... But it doesn't seem to work as expected, but I'm suspecting it to be broken with the current code as well (See screenshot), the fields are rendered outside of the Field groups.
Comment #46
jsacksick commentedOk, the attached patch fixes the integration with Field Group, I figured out what was causing the issue that also affects the current code.
I removed the
function_exists()call and only make use of the #process function (the #pre_render has been marked as deprecated in nov 2017).Comment #47
bojanz commentedSone cleanups, as discussed with jsacksick.
Comment #48
jsacksick commentedNow storing and retrieving the profiles from $form_state.
Renamed the widget from 'profile_inline' to 'profile_form'.
Comment #49
jsacksick commentedComment #50
jsacksick commentedWhen using the widget multiple times, the form #process and #submit callbacks were added twice, the attached patch fixes that.
Comment #52
bojanz commentedTweaked and committed. Thanks, everyone!
Comment #54
ckaotikPlease excuse me for butting in on a closed issue, but why was the
ProfileAccessTest.phpfile removed in the commit (but not in the patches)?Comment #55
john10080 commentedI got 2 out of 2 hunks FAILED -- saving rejects to file 2750059-50-register-widget.patch.rej while applying patch #50. Why?
Comment #56
jonathanshawBecaus the patch has already been committed and there's no point to applying it.
Comment #57
john10080 commentedBut Im not getting form modes in profile manage form display
-You can manage profiles on other user form modes as well. This was stated as benefit from the post T_T
Comment #58
john10080 commentedTo answer my Question, I found the form modes for profile at config > account > form-display then there's the option for add view mode for profile.
My problem now is how can I use the form mode I created in edit profile form? -_-