Needs review
Project:
CCK Private Fields
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Jun 2010 at 15:38 UTC
Updated:
17 Aug 2010 at 14:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
hixster commentedsubscribing
Comment #2
guillaumev commentedHi,
I'm using the dev version as well and, at user registration, I do not see the privacy icons. I see the privacy icons only on a user profile, after the user registered. I have my fields set to "Enabled and hidden by default"...
Comment #3
NaX commentedI am using the Content Profile module with user registration and I need CCK Private Fields to work.
The attached patch hacks in support when the Content Profile User Registration module is enabled.
I am using version 6.x-1.1.
Because the user registration form could be built from multiple node types I also changed the _cck_private_fields_node_form_alter() function to support being called multiple times.
The one major problem was that the Content Profile module removes other form fields including CCK Private Fields hidden fields that it needs to work. So I have also implemented a GLOBAL variable that is used to make sure these hidden fields are carried over into the form.
The patch seems to be working form me, but I don’t know if my implementation is the best way to be doing things.
The one thing I would like to be able to do in a better way but could not workout how was the adding of the js_settings.
I hope somebody else finds this useful.
Comment #4
NaX commentedPatch did not attach, I don’t know why.
Comment #5
markus_petrux commentedRe: "The one major problem was that the Content Profile module removes other form fields including CCK Private Fields hidden fields that it needs to work"
hmm... comparing module weights, I'm not sure about that. Could you please confirm?
- content_profile, weight: -1
- content_profile_registration, weight: 1
- cck_private_fields, weight: 10, so it should execute last.
Comment #6
NaX commented@markus_petrux
The module weights don’t play a role, because content_profile_registration retrieves the node forms and then loops through all the fields removing everything that should not be displayed on the user registration form.
The problem I ran into was that I got it to display the privacy icons but content profile was stripping out all the hidden fields preventing any values to be saved when the user registers.
I have not full investigated if there is some sort of method of integrating with the content profile module. I did notice a
module_invoke_all('content_profile_settings')but this was after I submitted the patch, and I can’t see how this hook would help solve our problem.One thing I thought of but have not tried yet is to alter the content profile settings form to include an option for
cck_private_fieldsand then hoping it will recognize it as fields that should not be removed.I don’t know cck_private_fields well enough to maybe write some code that alters the user_register form after content_profile_registration and does what is needed. Currently cck_private_fields only alters the node forms and on the user_register form content_profile_registration is in control of the node forms.
Heres an extract
REF: Line 22 and 106-181
http://drupalcode.org/viewvc/drupal/contributions/modules/content_profil...
Comment #7
NaX commentedI have completely re-looked this issue and I think I have found a much better way of doing this. The only thing is that this patch requires you don’t tick "Other form elements" under "Hide form fields" on the content profile node settings page if are using the Content Profile registration module.
In this patch I have moved both the wrapper code and the adding of the JS into their own pre_render functions. What led me to this was that on the registration form when validation found an error the private fields were not being rendered at all.
One major change is the introduction of a form delta. So each time a CCK Private Fields form is called and rendered it gets a new form delta. EG: $form['#cck_private_fields_0'] and $form['#cck_private_fields_1'].
This impacted the JS code and the node api code. I was hoping to prevent impacting the JS code because my JS coding is not very strong, but I got it to work with the delta rather easily in the end.
The main problem that led me to use a form delta was that content_profile_registration uses array concatenation to merge the form arrays. I tried it by hacking in an array_merge_recursive() but that just caused more problems.
@markus_petrux
Even if you decided not to support the content_profile_registration module and don’t like the form delta aspect of this patch, I do think the #pre_render method is worth a consideration.